Skip to main content

Notifications

Power Automate - Building Flows
Unanswered

use HTTP connector for x-www-form-urlencoded body (for Twittier API)

(0) ShareShare
ReportReport
Posted on by 9

I’m trying to use the twitter media API to upload an image and i’m struggling to understand how to structure the body of the HTTP connector into x-www-form-urlencoded body type. I've been trying to replicate the same using the Postman 'raw' body type and can't get it to work there either, but i can get it to work through the x-www-form-urlencoded body within Postman

If i create a variable ‘media=iVBORw0KGgoAAAANSUhEUgAAAAgAAAAIAQMAAAD+wSzIAAAABlBMVEX///+/v7+jQ3Y5AAAADklEQVQI12P4AIX8EAgALgAD/aNpbtEAAAAASUVORK5CYII’ I can generate a 200 response using the x-www-form-urlencoded body

 

scales23456_0-1713990294797.png

 

When i put the same body in Raw with a forced x-www-form-urlencoded header I get a 401 Unauthorized (which i think is just a poor error message bubbling up giving my Auth headers aren’t changing. The same thing happens in my PowerAutomate flow.

 

scales23456_1-1713990294788.png

 

I presumed this was to do with URLEncoding, so i encoded the value to the below, but this doesn't work in either PowerAutomate or the HTTP connector. Whats more confusing, is the encoded value stops the x-www-form-urlencoded tab working within Postman too. 

Does anyone know how to structure the HTTP conector body, so it will simulate the same behaviour I get when using the x-www-form-urlencoded tab?

Encoded
iVBORw0KGgoAAAANSUhEUgAAAAgAAAAIAQMAAAD%2BwSzIAAAABlBMVEX%2F%2F%2F%2B%2Fv7%2BjQ3Y5AAAADklEQVQI12P4AIX8EAgALgAD%2FaNpbtEAAAAASUVORK5CYII
Request:
POST https://upload.twitter.com/1.1/media/upload.json?
Documentation:
POST media/upload | Docs | Twitter Developer Platform

  • Jakeapril Profile Picture
    Jakeapril 33 on at
    use HTTP connector for x-www-form-urlencoded body (for Twittier API)
    scales23456's response worked for me! Had to change my Content-Type to application/x-www-form-urlencoded and in my body, have "'Key'='Value'". Thank you!
  • scales23456 Profile Picture
    scales23456 9 on at
    Re: use HTTP connector for x-www-form-urlencoded body (for Twittier API)

    No, unfortunately not. I've tried all combinations i could think of but they didn't work either.

     

    "key":"value"

    "key":value

    key:value

    key:"value"

    "key"="value"

    "key"=value

    key=value

    key="value"

     

    To date, the only place i can get it working is in the build in postman x-www-form-urlencoded body tab. Which confirms the API is working ultimately, but i presume there is some different formatting within there that i don't know. 

  • Re: use HTTP connector for x-www-form-urlencoded body (for Twittier API)

    Hi , @scales23456 

    Can you try to delete the "" in your body if it can help?

    media_data=iVBORw.........II

     

    Best Regards,

    Yueyun Zhang

     

     

     

  • scales23456 Profile Picture
    scales23456 9 on at
    Re: use HTTP connector for x-www-form-urlencoded body (for Twittier API)

    HTTP Connector for reference. I've tried every combination i can think of it the body

    scales23456_0-1713994950985.png

     

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,422

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,711

Leaderboard