Skip to main content

Notifications

Power Automate - Using Connectors
Unanswered

cannot "transform" a working cURL command for HTTP connector

(0) ShareShare
ReportReport
Posted on by 78

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 ?

 

  • artivo36 Profile Picture
    artivo36 78 on at
    Re: cannot "transform" a working cURL command for HTTP connector

    Got it !!!

     

    1st, the reference:

    https://powerusers.microsoft.com/t5/Building-Flows/HTTP-Post-multipart-form-data/td-p/145181powerusers.microsoft.com – 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.

  • artivo36 Profile Picture
    artivo36 78 on at
    Re: cannot "transform" a working cURL command for HTTP connector

    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.

     

  • murshed Profile Picture
    murshed on at
    Re: cannot "transform" a working cURL command for HTTP connector

    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?

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

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,495

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,822

Leaderboard

Featured topics