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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

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  



Anonymous
Not applicable

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

Anonymous
Not applicable

Need Token Key?

Well, for me is:

1 - Organizational account if you have one

2 - Web API

3 - Basic

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors