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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

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

6 REPLIES 6
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!


Hi @PhilipTreacy 

I've got a similar issue, i can run all these in postman with no issues, but PQ causes no end of problems. this is what i have, but it throws errors DataSource.Error: Web.Contents failed to get contents from 'https://myapidomain.com/v0/auth/code' (500): Internal Server Error
and
Expression.Error: We cannot convert a value of type Binary to type Text. Details: Value=[Binary] Type=[Type]


let
apiBaseUrl = #"API URL",
apiEmail = #"API Email",
accessCode = #"Access Code",

AuthUrl = apiBaseUrl & "/auth/code",

RawBody = "{
""meta"": {},
""data"": {
""email"": """ & apiEmail & """,
""code"": """ & accessCode & """
}
}",

Response = Web.Contents(
AuthUrl,
[
Headers = [
#"Content-Type" = "application/json",
#"Accept" = "application/json",
#"Accept-Language" = "en",
#"User-Agent" = "PostmanRuntime/7.32.0" // mimic Postman
],
Content = Text.ToBinary(RawBody, TextEncoding.Utf8)
]
),

ResponseText = Text.FromBinary(Response, TextEncoding.Utf8),
Parsed = Json.Document(ResponseText),
AccessToken = Parsed[data][access_token]
in
AccessToken

Is there a way to cater for a PUT request ?

 

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.

amitchandak
Super User
Super User

@ziyabikram96 , refer if this can help

https://eriksvensen.wordpress.com/2014/09/15/specifying-json-query-in-power-query-example-statistics...

 

Suggested in https://community.powerbi.com/t5/Desktop/Pull-data-from-API-using-POST-method-in-Power-BI/td-p/57472...

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Kudoed Authors