cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
atul-patil
Helper V
Helper V

How to access the data from POST API

Hi All,

 

I need to access the data from the POST API provided by the client

 

can anyone, please help me which option is used for to access the dataAPI.png

 

Thanks

3 REPLIES 3
SteveCampbell
Memorable Member
Memorable Member

You cannot pass authorization this way, the only way you can access is through selecting anonymous.

 

Instead, you must pass any authorization (such as Bearer Token) through the headers argument for web.contents.

 

In addition, to make it a POST request, you MUST add the argument of Content.

 

Here is a format I like. Note that i make the headerv and contentv both into JSON format first - this makes it easier to write and to view.


Take note of the argument [Headers = headerv, Content = Json.FromValue(contentv)]. As it is JSON I must convert the contentv using Json.FromValue. In addition, i've called Content-Type as application/json.

 

I should note, this particular query is to return an access token from OAUTH2. If you have one, you would include the parameter in the headers. 

 

Please don't copy the values, you will need to add the specific arguments to headersv and contentv as required.

 

 

headerv = [ 
#"Content-Type" = "application/json",
#"Accept" = "*/*"
],

contentv = [
#"grant_type" = "client_credentials",
#"client_id" = "{clientid}",
#"client_secret" = "{secret}"
],

Source = (Web.Contents("https://url/oauth2/token", [Headers = headerv, Content = Json.FromValue(contentv)])),

#"Imported JSON" = Json.Document(Source, 1252),

 



Did I answer your question? Mark my post as a solution! Proud to be a Super User!


Connect with me!
Stay up to date on  
Read my blogs on  



Thank you for your reply.

 

I have tried the most such codes before and this one also, but I don't know where is the fault:

 

What process I have applied in Postman: (Step by Step)

 

1. I have a URL to get the jwt key value:

    https://xxx(client website).azurewebsites.net/dev/auth/user/authenticate

2. Here I have passed the Body contents: (Payload)

 

      {

                "TenantId": "Client2",

                "UserSignon": "corp2019",

                "Password": "test"

    }

 3. From the second step, I got the "jwt"  value shows below

 

jwt.png

 

4. I having another URL where I have passed the KEY Name and Key-value generated from 2nd step(jwt)

 URL:  https://xxx(client website).azurewebsites.net/dev/master-data/departments/get

 KeyName: X-Token

Value: jwt generated passed here

 

5. Then I got the data which I have to access:

uilist.png

 

I request, can you please send me the code for the same process.

 

Thanks

DiegoReis
Advocate III
Advocate III

Need Token Key?

Well, for me is:

1 - Organizational account if you have one

2 - Web API

3 - Basic

Helpful resources

Announcements
PBI User Groups

Welcome to the User Group Public Preview

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

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Get Ready for Power BI Dev Camp

Power BI Dev Camp - June 24th

Mark your calendars and join us for our next Power BI Dev Camp!

Top Solution Authors
Top Kudoed Authors