Link to home
Start Free TrialLog in
Avatar of Michael Vasilevsky
Michael VasilevskyFlag for United States of America

asked on

"The parameter name url is not valid" on SharePoint REST API Call

I'm using the code example 2 found here, attempting to add a file to a list in a SharePoint Online add-in. I'm getting the error "The parameter name url is not valid" in the call to the function:

function addFileToFolder(arrayBuffer) {

        var fileName = $('#itemNumber').val() + "_image.png";

        var fileCollectionEndpoint = serverUrl + "_api/web/Lists/getByTitle('Pictures')/Files/Add(url='" + fileName + "', overwrite=true)"

        console.log(fileCollectionEndpoint);

        return jQuery.ajax({
            url: fileCollectionEndpoint,
            type: "POST",
            data: arrayBuffer,
            processData: false,
            headers: {
                "accept": "application/json;odata=verbose",
                "X-RequestDigest": myFormDigest,
                "content-length": arrayBuffer.byteLength
            }
        });
    }

Open in new window


fileCollectionEndpoint is:

"https://mySite-4642a56ed1c7b9.sharepoint.com/sites/develop_apps/PunchlistTracking/_api/web/Lists/getByTitle('Pictures')/Files/Add(url='myFile.png', overwrite=true)"

which is a valid API path. I'm not finding anything on this error online. Any ideas?
Avatar of dgrafx
dgrafx
Flag of United States of America image

I don't believe commas are valid in a URL
Remove it and test
Avatar of Michael Vasilevsky

ASKER

Try removing quotes then other chars if needed to find the issue
ASKER CERTIFIED SOLUTION
Avatar of Michael Vasilevsky
Michael Vasilevsky
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Only working solution provided