Forum Discussion

Sam2023's avatar
Sam2023
Frequent Visitor
2 years ago
Solved

PowerBi - Getting 404 but works in Postman

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.

  • 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. 

     

     

     

     

3 Replies

  • Sam2023's avatar
    Sam2023
    Frequent Visitor

    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. 

     

     

     

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      HI Sam2023,

      I'm glad to here you find the root casing about this issue.

      Regards,

      Xiaoxin Sheng