Batch request error invalid JSON body doesn't make sense

Ionut Calara 6 Reputation points
2021-05-18T09:05:40.233+00:00

Hi there,

I am trying to do a batch request to add a column to a table in excel, and I get the following error:

Client error: POST https://graph.microsoft.com/v1.0/$batch resulted in a 400 Bad Request response:
{"error":{"code":"BadRequest","message":"Invalid JSON body for request id : 1","innerError":{"date":"2021-05-18T08:58:53","request-id":"1694244a-9ef4-4cda-b28e-423f798842dd","client-request-id":"1694244a-9ef4-4cda-b28e-423f798842dd"}}}

The body is valid JSON: {"name":"Email"}

The request is /me/drive/items/fileidgoeshere/workbook/worksheets/{worksheetid}/tables/{table-id}/columns/add

I found this ticket, but I wasn't able to fix the problem by adding a space in the body payload. https://social.msdn.microsoft.com/Forums/en-US/293f8748-aec0-4093-867e-9b25d503313e/cannot-update-messages-through-rest-batch-request?forum=Office365forDevelopers

I

Not Monitored
Not Monitored
Tag not monitored by Microsoft.
39,702 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Ionut Calara 6 Reputation points
    2021-05-20T10:13:34.04+00:00

    Hi @Danstan, while fetching the request I found the issue. I am using the PHP SDK, and I sent the request body based on what the SDK creates. Because of that I was sending this "{\"name\":\"Last name\"}" which is not valid JSON. I was able to correct it by manually creating the request without using the sdk, and the endpoint worked. Thank you for the help.

    1 person found this answer helpful.
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.