Find a folder in OneDrive containing an apostrophe
Hi,
I want Zapier to find a folder in OneDrive by inputing data from a previous step.
The step that feeds data to this part returns “Customer Name - Customer Id”, and is put in the search folder part of my step.
Everything works ok most of the time, even when I input characters such as &, à, é or whatever we have in French.
The only cause of the problem seems to be when the customer has an apostrophe in his name.
No way to find a folder like “C’ustomer”. I even tried to let OneDrive create a new folder when it failed to find the first one, and mapped my search to the folder created instead. Same result. When there’s an apostrophe, everything seems to go wrong.
Any thoughts on how to prevent this from happening ?
Page 1 / 1
Hi @a
An apostrophe in a folder name will cause issues because it’s a ‘reserved character’ in a lot of code, which means it’s a character used in the code, so if there’s an apostrophe somewhere else, the code will get confused.
I Googled the issue and found this article, which suggests the following workaround:
All we need to do is “escape” the apostrophe. When you escape a character you essentially tell the script, “Look, the next character coming up is one of your reserved characters, but I don’t want you to use it as a reserved character; I want you to use it- in this case – as a plain old apostrophe.” To escape a reserved character in a WQL query, we just insert a \ in front of that character.
In this case that you would look for a folder called C\’ustomer
To add the backslash to the search value, use a Formatter by Zapier action and choose Text > Replace. Set up that step so that it finds apostrophes and replaces them with the slash and apostrophe.
Finally, use the output of the Formatter step in the Onedrive search step .
I hope that helps, please let us know if you have any questions!
Hi,
Thank you for helping me find a way to fix this.
I tried your solution and now have this error coming up :
“The app returned "Bad Request - Error in query syntax.".”
I suspect it has something to do with the way data is sent out, but I can’t seem to find a log of what the step actually tried to do.
Hi @Adeliand!
If this is still something you need help with, I think your best bet would be to contact our Support team so they can look into the detailed logs and see if there are any clues there about what is specifically going wrong.