Solved

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

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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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…

758 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

22 Experts available now in Live!

Get 1:1 Help Now