lundi 5 janvier 2015

REST api Bad Request file replace



I'm using sharepoint REST api using JavaScript to replace a file in a doc library. Here is the url structure I'm using.



<!-- language: lang-js -->

props.webUrl + "/_api/web/lists(guid'" + props.listId.slice(1, -1) + "')/RootFolder/Files/Add(url=@filename,overwrite=true)?@filename='" + encodeURIComponent(props.file.get_name()) + "'"


This call is not working if my filename contains apostrophe (ex: Shekar's.pptx). The browser is rejecting the call and throwing Bad request error and showing message like



The expression "web/lists(guid'cde87068-baf9-4863-910e-049bd7f3e04e')/RootFolder/Files/Add(Url='Shekar's.pptx',overwrite=true)" is not valid`.



I know the expression 'Shekar's.pptx'is wrong. I tried to encode with encodeUri, encodeUriComponent, escape and escapeProperly- None of them worked, still getting the same error messsage. Any ideas?








0 commentaires:

Enregistrer un commentaire