Solved

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

Posted on 2016-08-04
5
80 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

Suggested Solutions

These days socially coordinated efforts have turned into a critical requirement for enterprises.
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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…

710 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