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"
}
}
]
}

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