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
ziyabikram96
Helper V
Helper V

Not being able to access data via API Post Request

Hi,

I have been trying to import data using Trulinks Road Haulage Association, UK(RHA) APIs. Most of the API requests are POST while rest of them being GET. GET APIs have been straightforward while POST requests are posing problems. By Default, Web.Contents sends a GET request while a different approach is needed for POST.

ziyabikram96_0-1608720660347.png

ziyabikram96_1-1608720828765.png

 

How can I import data via POST request?

 

Thanks

1 ACCEPTED SOLUTION
PhilipTreacy
Super User
Super User

Hi @ziyabikram96 

Including Content in your request makes the Web.Contents perform a POST, for example:

 

 

Source = Json.Document(Web.Contents(url,[
Headers = [#"Content-Type"="application/json"],
Content = Text.ToBinary(body)
]
))

 

 

I don't know exactly what you need to provide in the request (e.g. API Auth,Headers) as I don' t know the API,but this should get you started.  Post back if you need further assistance.

regards

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


View solution in original post

4 REPLIES 4
ziyabikram96
Helper V
Helper V

Thank alot, Philip.

PhilipTreacy
Super User
Super User

Hi @ziyabikram96 

Including Content in your request makes the Web.Contents perform a POST, for example:

 

 

Source = Json.Document(Web.Contents(url,[
Headers = [#"Content-Type"="application/json"],
Content = Text.ToBinary(body)
]
))

 

 

I don't know exactly what you need to provide in the request (e.g. API Auth,Headers) as I don' t know the API,but this should get you started.  Post back if you need further assistance.

regards

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


What if the API requires Windows Authentication? 
Excel reports back that neither adding "contents" nor adding a method="POST" is allowed for anything but anonymous authentication. How do you post against an API behind Windows Authentication?

If you were building a C# application, it can easily use Windows Authentication to negotiate with the server, and you don't have to manually add the credentials either. It seems that post requests to Windows autorized APIs  would be a very common use case in corporate environments, but I have not found a way to do so in Power Query.

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.