Forum Discussion

AshishChadda18's avatar
AshishChadda18
New Member
1 year ago

Issue with POST API Call in Power BI

Hello everyone,
I’m trying to call an API from Power BI using Power Query M, but I'm encountering issues retrieving the expected publicToken. Here are the details of my situation:
 
What I’ve Tried:
  1. Constructed the API URL correctly with the master ID.
  2. Used the API key and secret for authentication.
  3. Attempted to extract the publicToken from the response JSON
 
Current Code:
 
let
    MasterID = [master.id],
    apiKey = "1234",
    apiKeySecret = "12345",
    url = "https://a.blazemeter.com/api/v4/masters/" & Text.From(MasterID) & "/public-token?api_key=" & apiKey & "&api_key_secret=" & apiKeySecret,
    response = Web.Contents(url),[
        Content=Text.ToBinary("")
    ])),
    Source = Json.Document(response),
    publicToken = try Source[result][publicToken] otherwise null
in
    publicToken
 
Error Message:
I received the following error:
DataSource.Error: Web.Contents with the Content option is only supported when connecting anonymously.
Details:
    DataSourceKind=Web
 

6 Replies

  • Thank you for the response lbendlin . I already tried the above approach but getting the below error: 

    Error Message: 

    DataSource.Error: Web.Contents with the Content option is only supported when connecting anonymously.
    Details: DataSourceKind=Web

    • lbendlin's avatar
      lbendlin
      Super User

      yes, you need to clear the permissions for that connection and choose anonymous.  Power Query has a bad habit of caching credentials, including the wrong ones you chose.

      • AshishChadda18's avatar
        AshishChadda18
        New Member

        Thanks again, the URL is dynamic but will look into this and update if there's any luck