web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / HTTP Request to ShareP...
Power Automate
Unanswered

HTTP Request to SharePoint with multpart form

(0) ShareShare
ReportReport
Posted on by 2

Hello everyone,

 

I am currently trying to update the default content of a document set content type using power automate.

After sniffing out the API calls made by the UI I was able to update the default content using Thunderclient (like Postman).

 

It's a PATCH request towards https://<tenant>.sharepoint.com/_api/v2.1/sites/<siteid>/contentTypes/<contentTypeId>

Content-Type = multipart/related; boundary=A100x

Body:

 

 

 

 

--A100x
Content-ID: metadata
Content-Type: application/json

{"pushDownChanges":true,"documentSet":{"shouldPrefixNameToFile":false,"propagateWelcomePageChanges":false,"defaultContents":[{"fileName":"aaa.txt","folderName":"Folder1/","contentType":{"id":"0x0101","name":"Dokument"},"@microsoft.graph.sourceUrl":"cid:content1"}]}}

--A100x
Content-ID: content1
Content-Type: application/octet-stream

asdasdsad
--A100x--

 

 

 

 

 

This is for setting the default content to a textfile named aaa.txt in Folder1 containing "asdasdsad".

 

I wanted to reproduce this in Power Automate using the action "Send an HTTP request to SharePoint", however it doesn't seem to work as it terminates with error "Unexpected response from the service".

 

The current attempt is the following:

 

Site Address: https://<tenant>.sharepoint.com

Uri: _api/v2.1/sites/<siteid>/contentTypes/0x0120D52000F5E5811F03FC2446AACB3F055A259FB5007C130CFFE997824196595A99086821F2?$expand=documentSet/sharedColumns,documentSet/welcomePageColumns

Body:

 

 

 

 

{
 "$content-type": "multipart/related",
 "$multipart": [
 {
 "headers": {
 "Content-ID": "metadata",
 "Content-Type": "application/json"
 },
 "body": {
 "$content": "{\"pushDownChanges\":true,\"documentSet\":{\"shouldPrefixNameToFile\":false,\"propagateWelcomePageChanges\":false,\"defaultContents\":[{\"fileName\":\"aaa.txt\",\"folderName\":\"Folder1/\",\"contentType\":{\"id\":\"0x0101\",\"name\":\"Dokument\"},\"@microsoft.graph.sourceUrl\":\"cid:content1\"}]}}",
 }
 },
 {
 "headers": {
 "Content-ID": "content1",
 "Content-Type": "application/octet-stream"
 },
 "body": {
 "$content": "asdasdsda"
 }
 }
 ]
}

 

 

 

 

 

Screenshot PowerAutomate.png

A get request with the same parameters (except the body) works, so the site and URI should be ok.

I'm pretty shure the problem is in the body.

What I've tried:

using "$content-type": "application/json" for body elements within multipart.

using "$content-type": "multipart/form" for the main body element

using single quotes in embedded json

 

Any help is appreciated!

Thank you

Categories:
I have the same question (0)
  • Expiscornovus Profile Picture
    33,183 Most Valuable Professional on at

    Hi @MartinZ1,

     

    Have you tried the v2.0 instead of the v2.1 version of the API? Not all methods seem to work with the v2.1 version in the Send an HTTP request to SharePoint action.

     

    Btw, this is a $batch type of request.

     

    So, technically you could first try the two request in separate Send an HTTP request to SharePoint actions with application/json content-type. This way you can more easily troubleshoot which request might be causing this.

  • MartinZ1 Profile Picture
    2 on at

    Hi @Expiscornovus ,

     

    thank you. I have tried the v2.0, however the response remains the same.

     

    I don't understand how I could split this up in two Send an HTTP request to SharePoint actions?

    The request body contains two parts. The first one is the metadata of the file, referencing the second part, which is the actual file content.

    If I where to send the file content in a second request, the reference in the first one would point to something that doesn't exist yet.

    Can you please explain how you would implement this?

     

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 523 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 406 Moderator

#3
abm abm Profile Picture

abm abm 245 Most Valuable Professional

Last 30 days Overall leaderboard