Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
I have some issues with Powerbi which is driving me insane.
Essentially, I have an API endpoint which accepts a JSON body:
{key1:"value1",key2:"value2"}
It is a GET request on an endpoint: https://website.com/api/v1/endpoint
When making the GET request in Postman, everything works fine, and it outputs the response with HTTP 200 OK. In PowerBi (blank query) however, it is returning a 404. I did a console.log on the endpoint, it outputs with Postman, but doesn't output when the same request is made from PowerBi (making me believe its not even reaching the URL).
The Postman body looks like this:
In PowerBi, I am doing this:
= let url = "https://website.com/api/v1/endpoint", body = "{""key1"": ""value1"",""key2"": ""value2""}", header = [#"Content-Type"= "application/json"], response = Web.Contents(url, [Content=Text.ToBinary(body),Headers = header]), Source = Json.Document(response) in Source
I am getting this as a response:
What is strange, is if I changed the PowerBi Text.ToBinary(body) to Json.FromValue(body), it does reach the endpoint and I can see in the console.log output, the following:
SyntaxError: Unexpected token " in JSON at position 0
at JSON.parse (<anonymous>)
PowerBi also returns this as an error (note this time it is a 400 and not a 404):
Any help would be massively appreciated!
The response from the API would return a JSON object which I would then parse into PowerBi as a dataset.
Solved! Go to Solution.
Thank you for the reply.
I should have been a bit more clear in my question.
The API requires the authentication and key:values in the body. It doesn't have support for url parameters.
Thank you for the reply.
I should have been a bit more clear in my question.
The API requires the authentication and key:values in the body. It doesn't have support for url parameters.
Hi @Sam2023,
Perhaps you can try to add optional parameters(e.g. relative path, authorization token in header) to the web connector if it help for your getting data operations:
Using The RelativePath And Query Options With Web.Contents () In Power Bi M Code
Regards,
Xiaoxin Sheng
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
4 | |
4 | |
3 | |
3 | |
3 |