Hi Diana Ivanova,
Thank you for reaching out, Microsoft!
The @microsoft.graph.conflictBehavior
attribute determines how conflicts are handled when a folder or file with the same name already exists. The three values you mentioned are:
replace: This should replace the existing item with the new one.
fail: This should fail the request if an item with the same name already exists.
rename: This should rename the new item to avoid a conflict.
From your description, it seems like using replace did not replace the existing folder but instead preserved it and its contents, which seems the justified behavior as it replaces particular drive item and not it's content. I tried to recreate the scenario and found that request does replaces the folder as lastModifiedDateTime changes for folder after API is executed but does not delete the files inside it.
Please refer the below screenshot:
Before API request
API request:
After POST request:
If my answer is helpful to this question, please remember to "Accept as answer" to close this case and this will help people in this forum who have similar questions to yours find the answer easier.