Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago

Simple API JSON "GET" call with a TOKEN (I already have a token)

I have not used PBI to perfom API calls in a while and things have certainly changed. I have looked around the internet and have found loads of suggestions but most don't understand the difference between a Token and a Key. Postman works fine.

 

With that, could I please acquire the updated and supported, simple and exact, Power Query syntax to pull API json data with a TOKEN, NOT a KEY. This seems simple enough but the syntax and requirements have changed and I am time constrained.

Thanks for your help!

TS

2 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous ,

     

    Please try

    let
        token = "your_token_here",
        url = "https://api.example.com/data",
        options = [
            Headers = [
                #"Authorization" = "Bearer " & token
            ]
        ],
        response = Web.Contents(url, options),
        json = Json.Document(response)
    in
        json

    Replace "your_token_here" with your actual token and "https://api.example.com/data" with the URL of the API endpoint you want to call. This code will send a GET request to the API endpoint with the token in the Authorization header and return the JSON response.


    Please note that you may need to modify the options variable to include additional headers or query parameters depending on the API you are calling.

     

    Similar post: Solved: How to pull data from Web API into PowerBI using A... - Microsoft Power BI Community

       

                                                                                                                                                             

    Best Regards,

    Stephen Tao

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.           

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thanks so much for your response, Stephen.

      What you shared should work but does not. I am not using any other Headers. Again, Postman works perfectly. I have two other API calls running to the same system but they don't require Tokens. I don't see any error messages and the only thing returned is the actual text in the API call.