5

I am doing a graph batch call to rename OneNote page title, I am following these samples provided on the graph website.

Following is the example with a single request for simplicity(typically in my scenario there are more than one requests).

POST https://graph.microsoft.com/v1.0/$batch

{  
   "requests":[  
      {  
         "id":"1",
         "method":"PATCH",
         "url":"https://graph.microsoft.com/v1.0/me/onenote/pages/1-98c2295df76a4067a6036efc6a8f6f74!84-f754d551-02d2-4416-af42-8fcc644f10e6/content",
         "headers":{  
            "Content-Type":"application/json"
         },
         "body":[  
            {  
               "target":"title",
               "action":"replace",
               "content":"2 - Test1"
            }
         ]
      }
   ]
}

I am getting a 400 response for this call with the following message

{
"error": {
    "code": "BadRequest",
    "message": "Invalid JSON body for request id : 1",
    "innerError": {
        "request-id": "2cc6bfcc-6ce5-471c-af37-181ef0dd5a9e",
        "date": "2018-10-22T10:06:54"
    }
  }
}

The same request if I do in a single call without batch it works fine. I have done enough investigation couldn't find any sample where an array is passed in the batch request body. Is it like array content is not supported in the batch request body or OneNote calls are not fully compatible with batching?.

Note: I tried giving the content in the body without array that also fails with the message "Specified method is not supported."

Deepak Sharma
  • 1,873
  • 10
  • 23
  • Have you tried to send your body as string? If you are doing to request in javascript, can you surround the body value in JSON.stringify()? – Brank Victoria Oct 22 '18 at 10:27
  • I have tried that, even tried base64 encoding as well both of these did not work. – Deepak Sharma Oct 22 '18 at 10:30
  • Any solutions here? I've also tried sending as JSON, as string, and as base64 string. Have tried this both with SDK and by constructing raw request as in this question, but nothing works. Works fine when NOT batching. – Freewalker Mar 14 '23 at 18:14

1 Answers1

-1

The url must be relative, as shown here

Try this with your code:

"url":"/me/onenote/pages/1-98c2295df76a4067a6036efc6a8f6f74!84-f754d551-02d2-4416-af42-8fcc644f10e6/content"

Peter Ciszewski
  • 609
  • 3
  • 6