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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
akashgera
Helper I
Helper I

Pull data from web service using POST method

Hello Folks,

I am fetching data from web service using POST method and using OAuth 2.0 authentication , which will generate access token using power query, after applying the query, I am getting an error: Invalid Client , I am passing client_secret, client_id & refresh token as per API docs in the content option, but getting an unexpected error:

let
url="https://accounts.zoho.com/oauth/v2/token",
contents=[#"refresh_token"="1000.1affXXXXXXXXXXXXXX"&
"client_id"="1000.WRXXXXXXXx"&
"client_secret"="10f6aaXXXXXXXXXX"&
"grant_type"="refresh_token"
],
result=Web.Contents(url,[Content=Json.FromValue(contents)]),
Final=Json.Document(result)

in
Final

 

When I pass the above parms in the POSTMAN it is giving me access token as requested, I don't know what is wrong in the above query, Pls help !!

 

Here is the link to the API docs- API Docs

 

Error from Power Bi :

akashgera_0-1628523803668.png

Screenshot from POSTMAN :

akashgera_1-1628523930149.png

 

Anykind of help would be appreciated, Thanks in advance !

@ImkeF,@TuanPham1999@sonet141@v-yuezhe-msft@v-yingjl  How to get data from a webservice with POST method,

Query RestAPI with POST Getting data from API with JSON body

4 REPLIES 4
mahoneypat
Microsoft Employee
Microsoft Employee

Please try this instead.  You need to make a record in your contents step.

 

= let
url="https://accounts.zoho.com/oauth/v2/token",
contents=[refresh_token="1000.1affXXXXXXXXXXXXXX",
client_id="1000.WRXXXXXXXx",
client_secret="10f6aaXXXXXXXXXX",
grant_type="refresh_token"
],
result=Web.Contents(url,[Content=Json.FromValue(contents)]),
Final=Json.Document(result)

in
Final

 

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Thanks for the response, I've tried with the below query as well, but still getting the same error: invalid_client

let
url="https://accounts.zoho.com/oauth/v2/token",
contents=[refresh_token="1000.1afXXXXXXXXXXXXXX",
client_id="1000.WXXXXXXXXXXXXXXXX",
client_secret="10fXXXXXXXXXXXX",
grant_type="refresh_token"
],
result=Web.Contents(url,[Content=Json.FromValue(contents)]),
Final=Json.Document(result)

in
Final

 

Not sure what the issue is but you can just hard code the whole url like this.  I saw the redirecturi in the documentation and see that you didn't have it (not sure if needed or not).  If this works, but you then have scheduled refresh issue, you can use the RelativePath and/or query paramters of Web.Contents.

 

let
url="https://accounts.zoho.com/oauth/v2/token",
refreshtoken="1000.1affXXXXXXXXXXXXXX",
clientid="1000.WRXXXXXXXx",
clientsecret="10f6aaXXXXXXXXXX",
granttype="refresh_token",
redirecturi = "????",
finalurl = "https://accounts.zoho.com/oauth/v2/token?refresh_token=" & refreshtoken & "&client_id=" & clientid & "&client_secret=" & clientsecret & "&redirect_uri=" & redirecturi & "&grant_type=" & granttype,
result=Web.Contents(finalurl),
Final=Json.Document(result)

in
Final

 

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


After checking again with the API docs, redirecturi is not the mandatory parameter to pass in the request call, As Postman is giving me the correct response without using redirecturi parameter that means, there is something wrong with my written query, I've followed your above written query, but now it is showing : Web.Contents failed to get contents from 'https://accounts.zoho.com/oauth/v2/token/

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

November Carousel

Fabric Community Update - November 2024

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

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.