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;
call req.AddParam("startDate","2021-04-20T12:24:36.971Z");
call req.AddParam("endDate","2021-04-21T12:24:36.971Z");
call req.AddParam("ascending","false");

new JsonObject jsonParam4;
call req.AddParam("accessToken",jsonParam4.Emit());

call req.AddHeader("Authorization","Bearer {{token}}");

new HttpResponse resp;
req.HttpVerb = "POST";
req.ContentType = "application/x-www-form-urlencoded";
success = http.PostUrlEncoded("https://domain.com/audit/v2/organizations/{{organization_id}}/query.csv", req,resp);
if (success == ckfalse) {
println http.LastErrorText;
return;
}

println resp.StatusCode;
println resp.BodyStr;

---- end chilkat script ----

unicodeC / Anypoint Platform APIs / Get csv formatted audit logs

Back to Collection Items

#include <C_CkHttpW.h>
#include <C_CkHttpRequestW.h>
#include <C_CkJsonObjectW.h>
#include <C_CkHttpResponseW.h>

void ChilkatSample(void)
    {
    HCkHttpW http;
    BOOL success;
    HCkHttpRequestW req;
    HCkJsonObjectW jsonParam4;
    HCkHttpResponseW resp;

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

    http = CkHttpW_Create();

    req = CkHttpRequestW_Create();
    CkHttpRequestW_AddParam(req,L"startDate",L"2021-04-20T12:24:36.971Z");
    CkHttpRequestW_AddParam(req,L"endDate",L"2021-04-21T12:24:36.971Z");
    CkHttpRequestW_AddParam(req,L"ascending",L"false");

    jsonParam4 = CkJsonObjectW_Create();
    CkHttpRequestW_AddParam(req,L"accessToken",CkJsonObjectW_emit(jsonParam4));

    CkHttpRequestW_AddHeader(req,L"Authorization",L"Bearer {{token}}");

    resp = CkHttpResponseW_Create();
    CkHttpRequestW_putHttpVerb(req,L"POST");
    CkHttpRequestW_putContentType(req,L"application/x-www-form-urlencoded");
ERROR: Assignment type mismatch.  ExpressionType=HttpResponse, atgType=ckbool

    if (success == FALSE) {
        wprintf(L"%s\n",CkHttpW_lastErrorText(http));
        CkHttpW_Dispose(http);
        CkHttpRequestW_Dispose(req);
        CkJsonObjectW_Dispose(jsonParam4);
        CkHttpResponseW_Dispose(resp);
        return;
    }

    wprintf(L"%d\n",CkHttpResponseW_getStatusCode(resp));
    wprintf(L"%s\n",CkHttpResponseW_bodyStr(resp));


    CkHttpW_Dispose(http);
    CkHttpRequestW_Dispose(req);
    CkJsonObjectW_Dispose(jsonParam4);
    CkHttpResponseW_Dispose(resp);

    }

Curl Command

curl -X POST
	-H "Authorization: Bearer {{token}}"
	--data-urlencode 'startDate=2021-04-20T12:24:36.971Z'
	--data-urlencode 'endDate=2021-04-21T12:24:36.971Z'
	--data-urlencode 'ascending=false'
	--data-urlencode 'accessToken={{token}}'
https://domain.com/audit/v2/organizations/{{organization_id}}/query.csv

Postman Collection Item JSON

{
  "name": "Get csv formatted audit logs",
  "request": {
    "method": "POST",
    "header": [
      {
        "key": "Authorization",
        "value": "Bearer {{token}}",
        "type": "text"
      }
    ],
    "body": {
      "mode": "urlencoded",
      "urlencoded": [
        {
          "key": "startDate",
          "value": "2021-04-20T12:24:36.971Z",
          "type": "text"
        },
        {
          "key": "endDate",
          "value": "2021-04-21T12:24:36.971Z",
          "type": "text"
        },
        {
          "key": "ascending",
          "value": "false",
          "type": "text"
        },
        {
          "key": "accessToken",
          "value": "{{token}}",
          "type": "text"
        }
      ]
    },
    "url": {
      "raw": "{{url}}/audit/v2/organizations/{{organization_id}}/query.csv",
      "host": [
        "{{url}}"
      ],
      "path": [
        "audit",
        "v2",
        "organizations",
        "{{organization_id}}",
        "query.csv"
      ]
    }
  },
  "response": [
  ]
}