Chilkat Online Tools

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("assertion",jsonParam1.Emit());
call req.AddParam("grant_type","urn:ietf:params:oauth:grant-type:jwt-bearer");

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 ----

delphiDll / DocuSign REST API / 02 JWT Access Token

Back to Collection Items

var
http: HCkHttp;
success: Boolean;
req: HCkHttpRequest;
jsonParam1: HCkJsonObject;
resp: HCkHttpResponse;

begin
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.

http := CkHttp_Create();

req := CkHttpRequest_Create();

jsonParam1 := CkJsonObject_Create();
CkHttpRequest_AddParam(req,'assertion',CkJsonObject__emit(jsonParam1));
CkHttpRequest_AddParam(req,'grant_type','urn:ietf:params:oauth:grant-type:jwt-bearer');

CkHttpRequest_AddHeader(req,'Authorization','Basic {{encodedKeys}}');

resp := CkHttpResponse_Create();
CkHttpRequest_putHttpVerb(req,'POST');
CkHttpRequest_putContentType(req,'application/x-www-form-urlencoded');
ERROR: Assignment type mismatch.  ExpressionType=HttpResponse, atgType=ckbool

if (success = False) then
  begin
    Memo1.Lines.Add(CkHttp__lastErrorText(http));
    Exit;
  end;

Memo1.Lines.Add(IntToStr(CkHttpResponse_getStatusCode(resp)));
Memo1.Lines.Add(CkHttpResponse__bodyStr(resp));

CkHttp_Dispose(http);
CkHttpRequest_Dispose(req);
CkJsonObject_Dispose(jsonParam1);
CkHttpResponse_Dispose(resp);

Curl Command

curl -X POST
	-H "Authorization: Basic {{encodedKeys}}"
	--data-urlencode 'assertion={{assertionHere}}'
	--data-urlencode 'grant_type=urn:ietf:params:oauth:grant-type:jwt-bearer'
https://{{hostenv}}/oauth/token

Postman Collection Item JSON

{
  "name": "02 JWT 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": "assertion",
          "value": "{{assertionHere}}"
        },
        {
          "key": "grant_type",
          "value": "urn:ietf:params:oauth:grant-type:jwt-bearer"
        }
      ]
    },
    "url": {
      "raw": "https://{{hostenv}}/oauth/token",
      "protocol": "https",
      "host": [
        "{{hostenv}}"
      ],
      "path": [
        "oauth",
        "token"
      ]
    }
  },
  "response": [
  ]
}