SharePoint API V2.0 $batch Requests

Eliot Cole 51 Reputation points
2024-10-24T18:50:37.95+00:00

Hello, I think this probably requires a relatively official response from Microsoft, but I'm looking to make batch requests via the SharePoint V2.0 method to push Graph $batch json POST bodies.

I cannot seem to get the request right, and I know that Graph can be persnicketty with how the request is formatted, so I thought I'd ask, here.

The Method for my request is: POST

The Uri I am posting to is the following, where TENANCY_NAME is the subdomain and SITE_PATH is the accepted path of the site: https://TENANCY_NAME.sharepoint.com/sites/SITE_PATH/_api/v2.0/$batch

My headers are as follows and I have also tried them with "application/json;odata.metadata=none" values:

{
  "Content-Type": "application/json",
  "Accept": "application/json"
}

The body that is being sent is as follows, where LIST_ID is the ID of the list I wish to get or post information to:

{
  "requests": [
    {
      "id": "01",
      "method": "GET",
      "url": "/lists/LIST_ID/items",
      "headers": {
        "Content-Type": "application/json;odata.metadata=none"
      }
    }
  ]
}

I have also tried the requests to include the full graph URL as such being as follows where SITE_ID is the ID of the site: https://graph.microsoft.com/v1.0/sites/SITE_ID/lists/LIST_ID/items

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
12,236 questions
SharePoint Development
SharePoint Development
SharePoint: A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.Development: The process of researching, productizing, and refining new or existing technologies.
3,030 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Yanli Jiang - MSFT 26,681 Reputation points Microsoft Vendor
    2024-10-25T09:57:33.04+00:00

    Hi @Eliot Cole ,

    Welcome to Q&A forum!

    Considering the convenience of use, I recommend you use Graph API. Pay attention to get the correct site id and list id.

    For your references:

    https://stackoverflow.com/questions/45406451/how-can-i-get-the-siteid-of-the-current-site-with-microsoft-graph-api

    https://learn.microsoft.com/en-us/graph/api/list-list?view=graph-rest-1.0&tabs=http

    Good day!


    If the answer is helpful, please click "Accept as Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


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.