Solved

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

Posted on 2016-08-04
5
44 Views
Last Modified: 2016-08-09
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?
0
Comment
Question by:Michael Vasilevsky
  • 3
  • 2
5 Comments
 
LVL 25

Expert Comment

by:dgrafx
ID: 41743559
I don't believe commas are valid in a URL
Remove it and test
0
 
LVL 10

Author Comment

by:Michael Vasilevsky
ID: 41743650
0
 
LVL 25

Expert Comment

by:dgrafx
ID: 41743655
Try removing quotes then other chars if needed to find the issue
0
 
LVL 10

Accepted Solution

by:
Michael Vasilevsky earned 0 total points
ID: 41743691
Not sure why, but this resolves the issue:

https://mysite-4642a56ed1c7b9.sharepoint.com/sites/develop_apps/PunchlistTracking/_api/web/getfolderbyserverrelativeurl('Lists/Pictures')/files/add(overwrite=true, url='CDA001-PL-0012_image.png')

Open in new window

0
 
LVL 10

Author Closing Comment

by:Michael Vasilevsky
ID: 41748477
Only working solution provided
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We had a requirement to extract data from a SharePoint 2010 Customer List into a CSV file and then place the CSV file into a directory on the network so that the file could be consumed by an AS400 system. I will share in Part 1 how to Extract the Da…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question