Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

REST API Post data connection to Power BI

Hi Team,

I want to connect REST API Post data to Power BI. I am able to generate the access token but not able to populate the data using POST method. I am referring below document

https://chris.koester.io/index.php/2015/07/16/get-data-from-twitter-api-with-power-query/#comment-23...

What would be the changes require in M query to generate the data using POST method( in above ref. link GET method used)

All help would be appreciated.

 

Regards,

Shailesh

2 REPLIES 2
v-kkf-msft
Community Support
Community Support

Hi @Anonymous ,

 

Web.Contents can take a second optional record argument.  Here is the syntax (with each of the record fields being optional):

 

Web.Contents("http://myurl.com",

[ ApiKeyName = "Bacon",
Content = "SomeHexOrText",
Query = [ Data1 = "A", Data2 = "B" ]])

As for those three record parameters, here is what they do:

Query: This parameter allows you to programmatically add query parameters to the URL without having to worry about escaping.  In the example above, the URL would be appended with ?Data1=A&Data2=B.
ApiKeyName: 
If your target site has some notion of an API key, this parameter allows you to specify the name (not the value) of the key parameter that must be used in the URL.  You specify the value of the Api key using the "Web API" credential option, so that you can send your document to someone else, and they would be able to use their own API key.  Technically, you can use the Query parameter to effect the same behavior, but then the API key and value would travel with the document.
Content: Specifying this value changes the web request from a GET to a POST, using the value of the Content field as the content of the POST.

 

The POST request is included in the document you share. https://chris.koester.io/index.php/2015/07/16/.... 

Generating a User Access Token:

      POST: https://api.twitter.com/oauth/request_token

let
 // Concatenates the Consumer Key & Consumer Secret and converts to base64
 authKey = "Basic " & Binary.ToText(Text.ToBinary("<ConsumerKey>:<ConsumerSecret>"),0),
 url = "https://api.twitter.com/oauth2/token",
 // Uses the Twitter POST oauth2/token method to obtain a bearer token
 GetJson = Web.Contents(url,
     [
         Headers = [#"Authorization"=authKey,
                    #"Content-Type"="application/x-www-form-urlencoded;charset=UTF-8"],
         Content = Text.ToBinary("grant_type=client_credentials") 
     ]
 ),
 FormatAsJson = Json.Document(GetJson),
 // Gets token from the Json response
 in
   FormatAsJson[access_token]

 

 

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

Thank you Winniz for the reply.

I am able to generate access token but not able performed next step. In the reference link, GET method has mentioned once access token has generated. In my my case i have to use POST method for access token as well as for data. 

ShaileshK_LT20_0-1654843522558.png

When I used query mentioned in the reference link,  getting below error:

ShaileshK_LT20_1-1654843697402.png

Regards,

Shailesh

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Kudoed Authors