Forum Discussion
Channel Advisor API Connection with auth key creation
- 4 years ago
Great! Cheers!
The response is in Json format, so you just need to add a step at the end of the custom function to extract access_token value. Don't forget to add a comma at the end of previous response step.
..................... response = Json.Document(Web.Contents(.......................)), access_token = response[access_token] in access_tokenJing
I am trying to use everybody's code snippets to connect to Channel Advisor's API. This part works:
() =>
let
url = "https://api.channeladvisor.com/oauth2/token",
headers = [#"Authorization"="Basic xxxxxxx="],
postBody = [
grant_type = "refresh_token",
refresh_token = "xxxxxxxx"
],
response = Json.Document(Web.Contents(url,
[
Headers = headers,
Content = Text.ToBinary(Uri.BuildQueryString(postBody))
])),
access_token = response[access_token]
in
access_token
What doesn't work is this part:
let
Source = Json.Document(Web.Contents("https://api.channeladvisor.com/oauth2/token",
[Headers=[#"Authorization"="bearer " & GetAccessToken(),
#"accept" = "text/plain",
#"Content-Type"="application/json"],
ManualStatusHandling = {404, 400}]))
in
Source
I have tried it with "Bearer" vs. "bearer" and a few other things, but either I get a 400 error OR the Power Query output simply gives me a small table that says "error | invalid client".
What am I doing wrong?
hi Anonymous ,
Could you try to replace your last query with:
let
Source = Json.Document(Web.Contents("search_url",
[Headers=[#"Authorization"= GetAccessToken(),
#"accept" = "text/plain",
#"Content-Type"="application/json"],
ManualStatusHandling = {404, 400}]))
in
Source- Anonymous3 years agoNot applicable
Thank you for responding. If I make that change, I get this error:
DataSource.Error: The remote name could not be resolved: 'search_url' Details: search_url- SomeDataDude3 years agoAdvocate I
Replace search_url in the query with your url: https://api.channeladvisor.com/oauth2/token
- Anonymous3 years agoNot applicable
That produces the "error | invalid client" response.