Forum Discussion
TrysHisBest
4 years agoNew Member
Channel Advisor API Connection with auth key creation
Afternoon All! Gonna be honest i'm racking my **bleep** brains out with this one but i'm getting no where. I tested a rest function in Postman and all works brilliant returning the data i nee...
- 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
lbendlin
Super User
3 years agoDid you notice there are two spaces after "Bearer" ?
SomeDataDude
Advocate I
3 years agoThanks for the trigger around Bearer. I put the Bearer &function in the other query. Now it is working.
Function:
() =>
let
content = "{
""mode"" : ""raw"",
""client_id"": ""************",
""client_secret"": ""*********""
}",
Source = Json.Document(Web.Contents("url_refreshtoken",
[Headers=[#"Authorization"="******",
#"accept" = "text/plain",
#"Content-Type"="application/json"],
ManualStatusHandling = {404, 400},
Content=Text.ToBinary(content)])),
access_token ="Bearer " &Source[access_token]
in
access_token
Query:
let
Source = Json.Document(Web.Contents("search_url",
[Headers=[#"Authorization"= GetAccessToken(),
#"accept" = "text/plain",
#"Content-Type"="application/json"],
ManualStatusHandling = {404, 400}]))
in
Source