API Call Works In Browser But Not In Script RRS feed

  • Question

  • 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:'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="" xmlns="" xmlns:d="" xmlns:m="" xmlns:georss="" xmlns: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.



    Friday, August 16, 2019 7:11 AM