Solved

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

Posted on 2016-08-04
5
34 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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…
This article discusses how to create an extensible mechanism for linked drop downs.
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…

867 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now