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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Anonymous
Not applicable

How to call or consume POST Rest API service in Power BI web Kindly help me to resolve

Hi Team,

How to call or consume POST Rest API service in Power BI web Kindly help me to resolve, GET method working properly but post method I am facing the error

13 REPLIES 13
Anonymous
Not applicable

HI  d_gosbell

                  As you mentioned I have made the changes but still, I am facing the issue Please find my code, kindly do the needful

 

let

        Source = Json.Document(Web.Contents("https://tmpldev.chainsys.com/apppublisher/rest/dataexchangerestpublisher/dataExchangeJsonExecution/X...", 

        [Headers=[Authorization="Basic bWFyaWFuaXRoaTpXZWxjb21lIzE="]])),

 

        Body = "{""parameters"" : {""recordsPerBatch"" : 10}}"

in

Source

arunican88888_0-1638873763141.png

 

You have not passed the Content= parameter in the options for the Web.Content call so your code will be doing a GET, not a POST. Maybe it should be something like the following

 

let

        Source = Json.Document(Web.Contents("https://tmpldev.chainsys.com/apppublisher/rest/dataexchangerestpublisher/dataExchangeJsonExecution/X...", 

        [Headers=[Authorization="Basic bWFyaWFuaXRoaTpXZWxjb21lIzE="], Content = "{""parameters"" : {""recordsPerBatch"" : 10}}" ])),

in

Source

Anonymous
Not applicable

Hi d_gosbell,

 

        Now I am Getting the bellow error , kindly do the needful

arunican88888_2-1638875695459.png

 

Expression.Error: We cannot convert the value "{"parameters" : {"re..." to type Binary.
Details:
Value={"parameters" : {"recordsPerBatch" : 10}}
Type=[Type]

So if the POST is expecting binary data try wrapping the content in the Text.ToBinary() function.

 

eg.

 

let

        Source = Json.Document(Web.Contents("https://tmpldev.chainsys.com/apppublisher/rest/dataexchangerestpublisher/dataExchangeJsonExecution/X...", 

        [Headers=[Authorization="Basic bWFyaWFuaXRoaTpXZWxjb21lIzE="], 
       Content = Text.ToBinary( "{""parameters"" : {""recordsPerBatch"" : 10}}" ) ])),

in

Source

Anonymous
Not applicable

Hi d_gosbell,

I am getting the bellow error kindly do the needful please.

arunican88888_0-1638933396385.png

let
url = "https://tmpldev.chainsys.com/apppublisher/rest/dataexchangerestpublisher/dataExchangeJsonExecution/X...",
Source = Json.Document(Web.Contents(url, [#"Headers"=[Authorization="Basic bWFyaWFuaXRoaTpXZWxjb21lIzE="],
Content = Text.ToBinary( "{""parameters"" : {""recordsPerBatch"" : 10}}" ) ]))
in
Source

I don't know what the problem is there. It looks like the request is working, but not returning any data. Does it work if you use another client like Postman to test the API?

Anonymous
Not applicable

Hi, d_gosbell,

 

As you suggested I have installed the fiddler and tested here is the result,

 

Post man request,

arunican88888_0-1638940381215.png

 

Power BI request

arunican88888_1-1638940381223.png

if you need any other information please let me know 

Anonymous
Not applicable

Hi d_gobell,

Yes, I did its working please find the screen shot below 

arunican88888_0-1638937039012.png

 

So you might need to use something like Fiddler to capture the call from Power BI and Postman and compare them to see what is different.

Anonymous
Not applicable

Hi d_gosbell,

 

As you suggested I have installed the fiddler and tested here is the result,

I can able see the result form postman

Postman request 1,

arunican88888_2-1638940960533.png

 

Postman request 2

arunican88888_3-1638940960537.png

 

Power BI request 1

arunican88888_4-1638940960543.png

 

 

Power BI request ..2

arunican88888_5-1638940960551.png

 

Anonymous
Not applicable

HI  d_gosbell

   I have tried with code which you have mentioned in the previous conversation, I am getting the below error , when I tried with anonymously which is through the error as

arunican88888_0-1638860526199.png

 

arunican88888_1-1638860526202.png

 

when I tried with Basis authentication which is through the error as

arunican88888_2-1638860526206.png

 

 

so that would have been helpful information to include in your original post. 

 

You can manually encode the basic authentication credentials using the technique outlined here

https://www.fourmoo.com/2020/09/16/using-power-query-to-get-data-from-an-api-that-uses-a-username-an... 

 

You would use an anonymous authentication type, but then pass through the Headers= option as in the above post to pass through the basic credentials and then also use the Content= to make the request a POST request.

d_gosbell
Super User
Super User

As shown in the second example for the Web.Contents function when you specify the Content= parameter the request is sent as a POST see https://docs.microsoft.com/en-us/powerquery-m/web-contents#example-2 

 

If you need more help you will need to explain to us what code you are running and show us the actual error message.

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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

Top Solution Authors