Forum Discussion
Connect to API - Bad Request Error
Hi pablopablo ,
Could you please use following query to see if the problem is in create the tekon request step?
let
//Create the variables
TokenURL = "xxx",
clientId = "xxx",
clientSecret = "xxx",
//Create the Token Request
GetJson = Web.Contents(TokenURL,[Headers = [#"Content-Type"="application/json"],Content = Text.ToBinary("{""clientId"":" & clientId &",""clientSecret"":"& clientSecret & "}")])
in
GetJson
we can also try to use some tools to see if power bi desktop has send the right web request, such as Fiddler Trace: https://docs.microsoft.com/en-us/power-bi/developer/embedded-troubleshoot
Best regards,
Hi,
I managed to get this working to the point where it is collecting a token and parsing it to the endpoint, however I am now getting an error - "Please specify how to conect"
code is:
/*
*/
let
//Create the variables
TokenURL = "xxx",
clientId = """xxx""",
clientSecret = """xxx""",
//Create the Token Request
GetJson = Web.Contents(TokenURL,
[
Headers = [#"Content-Type"="application/json"],
Content = Text.ToBinary("{""clientId"": " & clientId & ", ""clientSecret"": "& clientSecret & "}")
]
),
FormatAsJson = Json.Document(GetJson),
// Gets token from the Json response
AccessToken = FormatAsJson[access_token],
AccessTokenHeader = "bearer " & AccessToken,
// ???
GetJsonQuery = Web.Contents("xxx",
[
Headers=[#"wb-authorization"= AccessTokenHeader, ContentType="application/json"]
]
),
FormatAsJsonQuery = Json.Document(GetJsonQuery)
in
#"FormatAsJsonQuery"- v-lid-msft6 years agoCommunity Support
Hi pablopablo ,
It seems like add "" to the client fix the previous problem? If you got a warning like following, please try to edit with Anonymous since you have put the token inside the Header.
Best regards,- pablopablo6 years agoFrequent Visitor
Yeah I added the Anonymous but now getting this error
'We couldn't authenticate with the credentials provided. Please try again'
However I can see it create the token and parse it through. I try the token in postman and it works successfully.