I am working on a script that renames a OneNote Notebook. I have an API call that works when I run it in the browser but when I run it in the script it does not.
The API call is dynamic based on the name of the patient and their ID. In this case "Test, Test 123456". I get the API call from the Console.
In code I build the following and output it to the console:
https://site.sharepoint.com/_api/web/lists/getByTitle('Documents')/items?$select=Id,FileRef&$filter=substringof('/Shared%20Documents/Patients/Test,
Test 12346/2.%20Daily%20Notes/Patient a',FileRef)
This outputs.
<?xml version="1.0" encoding="utf-8"?><feed
xml:base="https://site.sharepoint.com/_api/"
xmlns="http://www.w3.org/2005/Atom"
xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices"
xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"
xmlns:georss="http://www.georss.org/georss"
xmlns:gml="http://www.opengis.net/gml"><id>04a45f71-c9ea-4e27-b447-afab53db054f</id><title
/><updated>2019-08-13T15:05:34Z</updated><author><name
/></author></feed>
I then use this code in the AJAX:
url: _spPageContextInfo.webAbsoluteUrl+"/_api/web/lists/getByTitle('Documents')/items?$select=Id,FileRef&$filter=substringof('" + onenote_path + "/2.%20Daily%20Notes/" + onenote_to_rename +"',FileRef)",
type: "GET",
headers: {
"accept": "application/json;odata=verbose",
"content-Type": "application/json;odata=verbose"
},
With this I am taken to the error function. I do not know what is different and why there would be an issue.
Thanks,
Steve