i tried to explain my problem.

I use jquery to upload in a Sharepoint list an image. The file for this image containt a single quote and space.

fileName="Test ' ";
var fileCollectionEndpoint = String.format(
                "{0}/_api/web/getfolderbyserverrelativeurl('{1}')/files" +
                "/add(overwrite=true, url='{2}')",
                serverUrl, serverRelativeUrlToFolder, fileName);
return jQuery.ajax(
        url: fileCollectionEndpoint,
        type: "POST",
        data: arrayBuffer,
        processData: false,
        headers: {
            "accept": "application/json;odata=verbose",
            "X-RequestDigest": jQuery("#__REQUESTDIGEST").val(),
            "content-length": arrayBuffer.byteLength
        success: function(result) {

The error is

{"error":{"code":"-1, Microsoft.SharePoint.Client.InvalidClientQueryException","message":{"lang":"fr-FR","value`enter code here`":"L'expression \u00ab\u00a0web/getfolderbyserverrelativeurl('bibli_photo_gare')/files/add(overwrite=true, url='test '.jpg')\u00a0\u00bb n'est pas valide."}}}

When i delete space and single quote, there is no error. Can someone help me ?

sorry for my english !!

  • Please try to use Curly quotes and save (Test ’ ) – Pradeep Kumar Jan 20 '18 at 18:45

You should have to detect when a file name has simple or double quotes. If it does, your final JS code should be like this, in this case:

fileName="Test \' ";

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.