cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
artivo
Frequent Visitor

cannot "transform" a working cURL command for HTTP connector

Hello all,

 

i wanto to use a  Flow to upload a file via REST.

when sending the corresponding command as cURL it works fine.

However, when importing the cURL into Postman (which is my blueprint for the HTTP connector) and trying from there, it fails with "unsupported media type".

I worked the last 3 days through all results Google shows me when searching for this or related error.

 

p.s. 

 

cURL command: 

curl -v -u <user:pass> -X POST "https://<url>/service/rest/v1/components?repository=<name>" -H "accept: application/json" -H "Content-Type: multipart/form-data" -F "maven2.groupId=1" -F "maven2.artifactId=1" -F "maven2.version=1" -F "maven2.asset1=@D:<path>\<file>;type=application/pdf" -F "maven2.asset1.extension=pdf"

 

(yes, its a Maven2 Repo @ Sonatype Nexus)

 

--> this works fine

 

However, i'm unable to format the HTTP connector in a way to make it work also via PowerAutomate

 

Ideas ?

 

3 REPLIES 3
murshed
Microsoft
Microsoft

Hi @artivo 

Unsupported media type usually indicates the media you are sending or receiving thru the HTTP connector. Can you please post the screenshot of the connector configuration you are using and the client request id from the error?

artivo
Frequent Visitor

Hi,

 

i was trying around a lot.

This is a screenshot from the last trial:

 

artivo_0-1618310620302.png

 

The error is alwas the same: "Unsupported Media Type"

 

Not sure what you mean with client request id.

Does this help:

 

artivo_1-1618310941560.png

 

From my understanding, this error comes from the destination-server / Sonatype Nexus.

Assuming their docu is correct they should be able to deal with JSON.

If so, i'm "simply" missing the right syntax.

 

artivo
Frequent Visitor

Got it !!!

 

1st, the reference:

https://powerusers.microsoft.com/t5/Building-Flows/HTTP-Post-multipart-form-data/td-p/145181poweruse... – 10 Aug 18

 


And this is how the body snippet must look like to make it work with Sonatype (Nexus Repository Manager).


{
“$content-type”: “multipart/form-data”,
“$multipart”:
[
{
“headers”:
{
“Content-Disposition”: “form-data; name=“maven2.groupId””
},
“body”: “1”
},
{
“headers”:
{
“Content-Disposition”: “form-data; name=“maven2.artifactId””
},
“body”: “1”
},
{
“headers”:
{
“Content-Disposition”: “form-data; name=“maven2.version””
},
“body”: “12”
},
{
“headers”:
{
“Content-Disposition”: "form-data; name=“maven2.asset1”;filename=“test.txt”
},
“body”: “SGVsbG8gV29ybGQ=”
},
{
“headers”:
{
“Content-Disposition”: “form-data; name=“maven2.asset1.extension””
},
“body”: “txt”
}
]
}

You can edit the values for the IDs to whatever you want or, what i am doing, connect them with values coming from a MS Forms document.
In this example, the value for the asset is a base64 encoded text (“Hello World”).
This is also intended to be connected to a file uploaded via MS Forms.

Helpful resources

Announcements
MPA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Users online (1,332)