Unable to update Sharepoint listitem with Microsoft GraphAPI in Python

Shankar, Pankaja 1 Reputation point
2023-01-24T21:51:26.3466667+00:00

Steps to reproduce:

  1. Create a new list with data given as { "displayName": "Books_2", "columns": [ { "name": "Book_author", "text": {"value": "JJ Solomon"} }, { "name": "Book_title", "text": {"value": "Computer Graphics"} } { "name": "Publication_year", "text": {"value": "1990"} } ], "list": { "template": "genericList" }
    }
  2. Create the listitems - works both in Postman and Python script with POST
  3. Lastly when I try to update one of the listitems I get a 400 BadRequest error, I even provided with the item etag, still the same error.

Below works fine in Postman but not in Python script using as a PATCH request

PATCH https://graph.microsoft.com/v1.0/sites/<my-siteid>/lists/<my-listid>/items/7/fields

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
11,448 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Shivam Dhiman 5,951 Reputation points
    2023-01-24T23:20:46.33+00:00

    Hi @Shankar, Pankaja

    400 BadRequest error indicates that the request is invalid. By looking at the endpoint provided it seems like there is an issue in Payload.

    Please make sure the field provided in Body is present in your SharePoint list.

    Also please make sure while updating field you are using internal value of the column.
    Please follow the below sample screenshot to get Internal value of your field.

    • Go to your list settings.

    sp1

    • Under columns got that particular column.

    sp2

    • In the above URL you can get field Internal Value which you need to use in Payload

    sp3

    After using the internal value, I am able to update that field. Please refer to the below sample screenshot:enter image description here

    Hope this helps.

    If the answer is helpful, please click Accept Answer and kindly upvote. If you have any further questions about this answer, please click Comment.

    0 comments No comments