cancel
Showing results for 
Search instead for 
Did you mean: 
Reply

Batch SharePoint API Calls from power automate

Hi,

 

I'm trying to implement the batch API calls to sharepoint list to create new items. The flow is getting executed successfully but the items are not getting created and I'm getting the below output from the http request .

 

{
  "$content-type": "multipart/mixed; boundary=batchresponse_cace2e0f-7b35-4382-af00-ad932f9e8888",
  "$content": "LS1iYXRjaHJlc3BvbnNlX2NhY2UyZTBmLTdiMzUtNDM4Mi1hZjAwLWFkOTMyZjllODg4OC0tDQo="
}

 

 

Originally, I wanted to add data from excel but for testing purpose, I hard coded the values (body below)

 

--batch_cd329ee8-ca72-4acf-b3bf-6699986af544
Content-Type: multipart/mixed; boundary="changeset_64c72699-6e7c-49c4-8d9b-6b16be92f7fc"
Content-Transfer-Encoding: binary
 
--changeset_64c72699-6e7c-49c4-8d9b-6b16be92f7fc
Content-Type: application/http
Content-Transfer-Encoding: binary
 
POST https://<tenant>.sharepoint.com/sites/<site>/_api/web/lists/GetByTitle('<title>')/items HTTP/1.1
Content-Type: application/json;odata=verbose 
{
    "__metadata": {
      "type": "SP.Data.<title>ListItem"
    },
    "Title": "Test"
}
--changeset_64c72699-6e7c-49c4-8d9b-6b16be92f7fc--
--batch_cd329ee8-ca72-4acf-b3bf-6699986af544--

 

 Please let me know where I might be missing something.

 

Thank you in advance

19 REPLIES 19
jinivthakkar
Community Champion
Community Champion

@murshed @v-litu-msft I too tried everything nothing works, can you please post a working example ?

v-litu-msft
Community Support
Community Support

Hi @Suchitra1996,

 

I think the headers in your HTTP request are not correct, you could refer to by following screenshots to structure it:

Screenshot 2021-02-12 133744.jpg

 

For more details about lists and list items API, you could refer to this document, you will find the Create item API:

Working with lists and list items with REST | Microsoft Docs

 

Best Regards,
Community Support Team _ Lin Tu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

jinivthakkar
Community Champion
Community Champion

@v-litu-msft thanks for your reply but I think the issue is with _api/$batch end point POST, the regular POST which you showed just works fine.

 

The issue is with batch insert operation like this 

 

https://ashiqf.com/2020/06/16/batch-sharepoint-requests-get-post-patch-delete-in-powerautomate-and-m...

 

Please help

 

jinivthakkar
Community Champion
Community Champion

@v-litu-msft one more similar blog/article but this also does not work :

 

https://wiliammbr.com/batch-insert-items-in-sharepoint-with-power-automate/

 

 

Hi @v-litu-msft,

 

This is the header of my request for the batch API request.

 

I have entered the batch ID in the header request and the same batch ID is in the body of the request.

 

Suchitra1996_0-1613114801593.png

Suchitra1996_1-1613114871606.png

 

 

I get the below output when I execute it:

Suchitra1996_2-1613114915677.png

 

While the flow ran successfully, there was no item created in the list.

 

Anonymous
Not applicable

Did you get this resolved? I got batch posts working

I can share if you are still trying to work on this I am typing on iPad right now but can share full solution if you need it

swiftinitdotcom
Frequent Visitor

swiftinitdotcom_0-1637755083579.png
can you please share?
Kem-El
Regular Visitor

Late to the game on this, but you simply need to add a blank line between the start and end of the JSON data.

 

 

--batch_cd329ee8-ca72-4acf-b3bf-6699986af544
Content-Type: multipart/mixed; boundary="changeset_64c72699-6e7c-49c4-8d9b-6b16be92f7fc"
Content-Transfer-Encoding: binary
 
--changeset_64c72699-6e7c-49c4-8d9b-6b16be92f7fc
Content-Type: application/http
Content-Transfer-Encoding: binary
 
POST https://<tenant>.sharepoint.com/sites/<site>/_api/web/lists/GetByTitle('<title>')/items HTTP/1.1
Content-Type: application/json;odata=verbose 

{
    "__metadata": {
      "type": "SP.Data.<title>ListItem"
    },
    "Title": "Test"
}

--changeset_64c72699-6e7c-49c4-8d9b-6b16be92f7fc--
--batch_cd329ee8-ca72-4acf-b3bf-6699986af544--

 

takolota
Multi Super User
Multi Super User

Hi @takolota 
I am using same template as Paula's and now I am getting failure at send Batch with Bad HTTP request 400.
I got this error message - 
The maximum number of bytes allowed to be read from the stream has been exceeded. After the last read operation, a total of 1055877 bytes has been read from the stream; however a maximum of 1048576 bytes is allowed.(…)

I tried using batch size to 750 and even 50 , but still it is same. Can you pls help?

How many columns are you using?

7 columns

The only thing I am doing here is that , putting Generate SP data inside an apply loop as I am getting mapping values from excel

alexa_028_0-1693574614479.png

 

@alexa_028 

You're not using the same as Paulie's default template because I don't see any reason why you would put that into an Apply to each. If that run was actually successful, I'd bet you'd get a copy of every Excel row into SharePoint FOR EACH excel row. So if you had 100 rows in excel it would copy all 100 rows 100 times for a total of 10,000 rows.

You do not need that Apply to each, the Select action already has a kind of internal Apply to each loop going through every value in the From field, in this case going through every value from the Excel list rows.

Hey @takolota 
I changed to the template and and now everything works but it doesn't add the data to sharepoint due to the error :

HTTP/1.1 400 Bad Request
CONTENT-TYPE: application/json;odata=verbose;charset=utf-8

{"error":{"code":"-1, Microsoft.SharePoint.Client.InvalidClientQueryException","message":{"lang":"en-US","value":"A type named 'SP.Data.CoreHRListItem' could not be resolved by the model. When a model is available, each type name must resolve to a valid type."}}}
--batchresponse_af4cf4cf-f945-46a2-913f-e1409e785318
Content-Type: application/http
Content-Transfer-Encoding: binary

Few things I did but no luck :
1. Removed apply each loop from GenerateSPData block

2. Changed the action formula from "trackedProperties" to "TrackedProperties"

alexa_028_0-1693822354729.pngalexa_028_1-1693822377710.pngalexa_028_2-1693822440436.png

 

@alexa_028 

 

What do you have for the CoreHR column in the GenerateSPData action? And what datatype is it in the SharePoint list?

Hi,

I have solved my issue using the comment from Will in this article. It was very helpful. Basically my sharepoint display name was not same as web address name.

https://www.tachytelic.net/2021/06/power-automate-flow-batch-create-sharepoint-list-items/


More info posted here : https://powerusers.microsoft.com/t5/General-Power-Automate/ERROR-BAD-REQUEST/m-p/2331781#M138204

@alexa_028 

Are you working from an older version?
I thought I patched that common issue with an extra call to SharePoint to use the current list display name to get the original back-end name.

Hi, have you found any solution? 
I've the very same problem...

Helpful resources

Announcements

Community will be READ ONLY July 16th, 5p PDT -July 22nd

Dear Community Members,   We'd like to let you know of an upcoming change to the community platform: starting July 16th, the platform will transition to a READ ONLY mode until July 22nd.   During this period, members will not be able to Kudo, Comment, or Reply to any posts.   On July 22nd, please be on the lookout for a message sent to the email address registered on your community profile. This email is crucial as it will contain your unique code and link to register for the new platform encompassing all of the communities.   What to Expect in the New Community: A more unified experience where all products, including Power Apps, Power Automate, Copilot Studio, and Power Pages, will be accessible from one community.Community Blogs that you can syndicate and link to for automatic updates. We appreciate your understanding and cooperation during this transition. Stay tuned for the exciting new features and a seamless community experience ahead!

Summer of Solutions | Week 4 Results | Winners will be posted on July 24th

We are excited to announce the Summer of Solutions Challenge!    This challenge is kicking off on Monday, June 17th and will run for (4) weeks.  The challenge is open to all Power Platform (Power Apps, Power Automate, Copilot Studio & Power Pages) community members. We invite you to participate in a quest to provide solutions to as many questions as you can. Answers can be provided in all the communities.    Entry Period: This Challenge will consist of four weekly Entry Periods as follows (each an “Entry Period”)   - 12:00 a.m. PT on June 17, 2024 – 11:59 p.m. PT on June 23, 2024 - 12:00 a.m. PT on June 24, 2024 – 11:59 p.m. PT on June 30, 2024 - 12:00 a.m. PT on July 1, 2024 – 11:59 p.m. PT on July 7, 2024 - 12:00 a.m. PT on July 8, 2024 – 11:59 p.m. PT on July 14, 2024   Entries will be eligible for the Entry Period in which they are received and will not carryover to subsequent weekly entry periods.  You must enter into each weekly Entry Period separately.   How to Enter: We invite you to participate in a quest to provide "Accepted Solutions" to as many questions as you can. Answers can be provided in all the communities. Users must provide a solution which can be an “Accepted Solution” in the Forums in all of the communities and there are no limits to the number of “Accepted Solutions” that a member can provide for entries in this challenge, but each entry must be substantially unique and different.    Winner Selection and Prizes: At the end of each week, we will list the top ten (10) Community users which will consist of: 5 Community Members & 5 Super Users and they will advance to the final drawing. We will post each week in the News & Announcements the top 10 Solution providers.  At the end of the challenge, we will add all of the top 10 weekly names and enter them into a random drawing.  Then we will randomly select ten (10) winners (5 Community Members & 5 Super Users) from among all eligible entrants received across all weekly Entry Periods to receive the prize listed below. If a winner declines, we will draw again at random for the next winner.  A user will only be able to win once overall. If they are drawn multiple times, another user will be drawn at random.  Individuals will be contacted before the announcement with the opportunity to claim or deny the prize.  Once all of the winners have been notified, we will post in the News & Announcements of each community with the list of winners.   Each winner will receive one (1) Pass to the Power Platform Conference in Las Vegas, Sep. 18-20, 2024 ($1800 value). NOTE: Prize is for conference attendance only and any other costs such as airfare, lodging, transportation, and food are the sole responsibility of the winner. Tickets are not transferable to any other party or to next year’s event.   ** PLEASE SEE THE ATTACHED RULES for this CHALLENGE**   Week 1 Results: Congratulations to the Week 1 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge.   Community MembersNumber SolutionsSuper UsersNumber Solutions Deenuji 9 @NathanAlvares24  17 @Anil_g  7 @ManishSolanki  13 @eetuRobo  5 @David_MA  10 @VishnuReddy1997  5 @SpongYe  9JhonatanOB19932 (tie) @Nived_Nambiar  8 @maltie  2 (tie)   @PA-Noob  2 (tie)   @LukeMcG  2 (tie)   @tgut03  2 (tie)       Week 2 Results: Congratulations to the Week 2 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 2: Community MembersSolutionsSuper UsersSolutionsPower Automate  @Deenuji  12@ManishSolanki 19 @Anil_g  10 @NathanAlvares24  17 @VishnuReddy1997  6 @Expiscornovus  10 @Tjan  5 @Nived_Nambiar  10 @eetuRobo  3 @SudeepGhatakNZ 8     Week 3 Results: Congratulations to the Week 3 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 3:Community MembersSolutionsSuper UsersSolutionsPower Automate Deenuji32ManishSolanki55VishnuReddy199724NathanAlvares2444Anil_g22SudeepGhatakNZ40eetuRobo18Nived_Nambiar28Tjan8David_MA22   Week 4 Results: Congratulations to the Week 4 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 4:Community MembersSolutionsSuper UsersSolutionsPower Automate Deenuji11FLMike31Sayan11ManishSolanki16VishnuReddy199710creativeopinion14Akshansh-Sharma3SudeepGhatakNZ7claudiovc2CFernandes5 misc2Nived_Nambiar5 Usernametwice232rzaneti5 eetuRobo2   Anil_g2   SharonS2  

Check Out | 2024 Release Wave 2 Plans for Microsoft Dynamics 365 and Microsoft Power Platform

On July 16, 2024, we published the 2024 release wave 2 plans for Microsoft Dynamics 365 and Microsoft Power Platform. These plans are a compilation of the new capabilities planned to be released between October 2024 to March 2025. This release introduces a wealth of new features designed to enhance customer understanding and improve overall user experience, showcasing our dedication to driving digital transformation for our customers and partners.    The upcoming wave is centered around utilizing advanced AI and Microsoft Copilot technologies to enhance user productivity and streamline operations across diverse business applications. These enhancements include intelligent automation, AI-powered insights, and immersive user experiences that are designed to break down barriers between data, insights, and individuals. Watch a summary of the release highlights.    Discover the latest features that empower organizations to operate more efficiently and adaptively. From AI-driven sales insights and customer service enhancements to predictive analytics in supply chain management and autonomous financial processes, the new capabilities enable businesses to proactively address challenges and capitalize on opportunities.    

Updates to Transitions in the Power Platform Communities

We're embarking on a journey to enhance your experience by transitioning to a new community platform. Our team has been diligently working to create a fresh community site, leveraging the very Dynamics 365 and Power Platform tools our community advocates for.  We started this journey with transitioning Copilot Studio forums and blogs in June. The move marks the beginning of a new chapter, and we're eager for you to be a part of it. The rest of the Power Platform product sites will be moving over this summer.   Stay tuned for more updates as we get closer to the launch. We can't wait to welcome you to our new community space, designed with you in mind. Let's connect, learn, and grow together.   Here's to new beginnings and endless possibilities!   If you have any questions, observations or concerns throughout this process please go to https://aka.ms/PPCommSupport.   To stay up to date on the latest details of this migration and other important Community updates subscribe to our News and Announcements forums: Copilot Studio, Power Apps, Power Automate, Power Pages

Users online (1,464)