Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
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
User | Count |
---|---|
5 | |
4 | |
4 | |
2 | |
2 |
User | Count |
---|---|
8 | |
6 | |
4 | |
4 | |
4 |