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

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MSFTBizAppsLaunchEvent

Experience what’s next for Power Virtual Agents

See the latest Power Automate innovations, updates, and demos from the Microsoft Business Applications Launch Event.

New Super Users

Meet the Power Automate Super Users!

Many congratulations to the Season 1 2021 Flownaut Crew!

Power Platform ISV STudio

Power Platform ISV Studio

ISV Studio is the go-to Power Platform destination for ISV’s to monitor & manage applications post-AppSource publish.

Users online (9,317)