Chilkat Online Tools

C / LHDN MyInvois SDK / Login as Intermediary System

Back to Collection Items

#include <C_CkHttp.h>
#include <C_CkHttpRequest.h>
#include <C_CkHttpResponse.h>

void ChilkatSample(void)
    {
    HCkHttp http;
    BOOL success;
    HCkHttpRequest req;
    HCkHttpResponse resp;

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

    http = CkHttp_Create();

    req = CkHttpRequest_Create();
    CkHttpRequest_AddParam(req,"grant_type","client_credentials");
    CkHttpRequest_AddParam(req,"scope","InvoicingAPI");

    CkHttpRequest_AddHeader(req,"client_id","{{clientId}}");
    CkHttpRequest_AddHeader(req,"grant_type","client_credentials");
    CkHttpRequest_AddHeader(req,"onbehalfof","100015840");
    CkHttpRequest_AddHeader(req,"client_secret","{{clientSecret}}");

    resp = CkHttp_PostUrlEncoded(http,"https://{{apiBaseUrl}}/connect/token",req);
    if (CkHttp_getLastMethodSuccess(http) == FALSE) {
        printf("%s\n",CkHttp_lastErrorText(http));
        CkHttp_Dispose(http);
        CkHttpRequest_Dispose(req);
        return;
    }

    printf("%d\n",CkHttpResponse_getStatusCode(resp));
    printf("%s\n",CkHttpResponse_bodyStr(resp));
    CkHttpResponse_Dispose(resp);


    CkHttp_Dispose(http);
    CkHttpRequest_Dispose(req);

    }

Curl Command

curl -X POST
	-H "client_id: {{clientId}}"
	-H "client_secret: {{clientSecret}}"
	-H "onbehalfof: 100015840"
	-H "grant_type: client_credentials"
	--data-urlencode 'grant_type=client_credentials'
	--data-urlencode 'scope=InvoicingAPI'
https://{{apiBaseUrl}}/connect/token

Postman Collection Item JSON

{
  "name": "Login as Intermediary System",
  "request": {
    "method": "POST",
    "header": [
      {
        "key": "client_id",
        "value": "{{clientId}}",
        "type": "text",
        "uuid": "df451b49-4e2b-4868-a180-1d01df266117"
      },
      {
        "key": "client_secret",
        "value": "{{clientSecret}}",
        "type": "text",
        "uuid": "c693de12-7723-4be2-aec1-00c1cdc7a797"
      },
      {
        "key": "onbehalfof",
        "value": "100015840",
        "type": "text",
        "uuid": "d55cb4b6-59f8-4f19-95a2-db6780b8152d"
      },
      {
        "key": "grant_type",
        "value": "client_credentials",
        "type": "text",
        "uuid": "7386ca83-cce5-4b62-bcb0-06e464a3b67f"
      }
    ],
    "body": {
      "mode": "urlencoded",
      "urlencoded": [
        {
          "key": "grant_type",
          "value": "client_credentials",
          "type": "text"
        },
        {
          "key": "scope",
          "value": "InvoicingAPI",
          "type": "text"
        }
      ]
    },
    "url": {
      "raw": "https://{{apiBaseUrl}}/connect/token",
      "protocol": "https",
      "host": [
        "{{apiBaseUrl}}"
      ],
      "path": [
        "connect",
        "token"
      ]
    }
  },
  "response": [
  ]
}