ERROR!
------------------- GenerateCode ----------------------
ImpliedContentType: application/x-www-form-urlencoded
---- begin chilkat script ----
// This example assumes the Chilkat API to have been previously unlocked.
// See {{-global_unlock:::Global Unlock Sample-}} for sample code.
new Http http;
ckbool success;
new HttpRequest req;
new JsonObject jsonParam1;
call req.AddParam("refresh_token",jsonParam1.Emit());
call req.AddHeader("Authorization","Basic {{encodedKeys}}");
new HttpResponse resp;
req.HttpVerb = "POST";
req.ContentType = "application/x-www-form-urlencoded";
success = http.PostUrlEncoded("https://{{hostenv}}/oauth/token", req,resp);
if (success == ckfalse) {
println http.LastErrorText;
return;
}
println resp.StatusCode;
println resp.BodyStr;
---- end chilkat script ----
Back to Collection Items
// This example assumes the Chilkat API to have been previously unlocked.
// See Global_Ref.html">Global_Ref.html">Global_Ref.html">Global_Ref.html">Global_Ref.html">Global_Ref.html">Global_Ref.html">Global Unlock Sample for sample code.
http := Http_Ref.html">Http_Ref.html">Http_Ref.html">Http_Ref.html">Http_Ref.html">Http_Ref.html">Http_Ref.html">chilkat.NewHttp()
var success bool
req := HttpRequest_Ref.html">HttpRequest_Ref.html">HttpRequest_Ref.html">HttpRequest_Ref.html">HttpRequest_Ref.html">HttpRequest_Ref.html">HttpRequest_Ref.html">chilkat.NewHttpRequest()
jsonParam1 := JsonObject_Ref.html">JsonObject_Ref.html">JsonObject_Ref.html">JsonObject_Ref.html">JsonObject_Ref.html">JsonObject_Ref.html">JsonObject_Ref.html">chilkat.NewJsonObject()
req.AddParam("refresh_token",*jsonParam1.Emit())
req.AddHeader("Authorization","Basic {{encodedKeys}}")
resp := HttpResponse_Ref.html">HttpResponse_Ref.html">HttpResponse_Ref.html">HttpResponse_Ref.html">HttpResponse_Ref.html">HttpResponse_Ref.html">HttpResponse_Ref.html">chilkat.NewHttpResponse()
req.SetHttpVerb("POST")
req.SetContentType("application/x-www-form-urlencoded")
ERROR: Assignment type mismatch. ExpressionType=HttpResponse_Ref.html">HttpResponse_Ref.html">HttpResponse_Ref.html">HttpResponse_Ref.html">HttpResponse_Ref.html">HttpResponse_Ref.html">HttpResponse_Ref.html">HttpResponse, atgType=ckbool
if success == false {
fmt.Println(http.LastErrorText())
http.DisposeHttp()
req.DisposeHttpRequest()
jsonParam1.DisposeJsonObject()
resp.DisposeHttpResponse()
return
}
fmt.Println(resp.StatusCode())
fmt.Println(resp.BodyStr())
http.DisposeHttp()
req.DisposeHttpRequest()
jsonParam1.DisposeJsonObject()
resp.DisposeHttpResponse()
Curl Command
curl -X POST
-H "Authorization: Basic {{encodedKeys}}"
--data-urlencode 'refresh_token={{refreshToken}}'
https://{{hostenv}}/oauth/token
Postman Collection Item JSON
{
"name": "03 Refresh Access Token",
"event": [
{
"listen": "test",
"script": {
"type": "text/javascript",
"exec": [
"var jsonData = JSON.parse(responseBody);",
"postman.setEnvironmentVariable(\"accessToken\", jsonData.access_token);",
"var jsonData = JSON.parse(responseBody);",
"postman.setEnvironmentVariable(\"refreshToken\", jsonData.refresh_token);"
]
}
}
],
"request": {
"method": "POST",
"header": [
{
"key": "Authorization",
"value": "Basic {{encodedKeys}}"
}
],
"body": {
"mode": "urlencoded",
"urlencoded": [
{
"key": "refresh_token",
"value": "{{refreshToken}}"
}
]
},
"url": {
"raw": "https://{{hostenv}}/oauth/token",
"protocol": "https",
"host": [
"{{hostenv}}"
],
"path": [
"oauth",
"token"
]
}
},
"response": [
]
}