Chilkat Online Tools

delphiDll / Egyptian eInvoicing SDK R1.5 / 2. Get Document Types

Back to Collection Items

var
http: HCkHttp;
success: Boolean;
json: HCkJsonObject;
sbRequestBody: HCkStringBuilder;
resp: HCkHttpResponse;

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

http := CkHttp_Create();

// Use this online tool to generate code from sample JSON: Generate Code to Create JSON

// The following JSON is sent in the request body.

// {
//   "documentTypeCodeName": "creditupdated",
//   "namePrimaryLang": "CreditEn",
//   "nameSecondaryLang": "CreditAr",
//   "descriptionPrimaryLang": "Des-creditEn",
//   "descriptionSecondaryLang": "Des-creditAr",
//   "activeFrom": "2020-06-09T07:38:54.836Z"
// }

json := CkJsonObject_Create();
CkJsonObject_UpdateString(json,'documentTypeCodeName','creditupdated');
CkJsonObject_UpdateString(json,'namePrimaryLang','CreditEn');
CkJsonObject_UpdateString(json,'nameSecondaryLang','CreditAr');
CkJsonObject_UpdateString(json,'descriptionPrimaryLang','Des-creditEn');
CkJsonObject_UpdateString(json,'descriptionSecondaryLang','Des-creditAr');
CkJsonObject_UpdateString(json,'activeFrom','2020-06-09T07:38:54.836Z');

// Adds the "Authorization: Bearer <access_token>" header.
CkHttp_putAuthToken(http,'<access_token>');
CkHttp_SetRequestHeader(http,'Accept-Language','ar');

sbRequestBody := CkStringBuilder_Create();
CkJsonObject_EmitSb(json,sbRequestBody);

resp := CkHttp_PTextSb(http,'GET','https://domain.com/api/v1/documenttypes',sbRequestBody,'utf-8','application/json',False,False);
if (CkHttp_getLastMethodSuccess(http) = False) then
  begin
    Memo1.Lines.Add(CkHttp__lastErrorText(http));
    Exit;
  end;

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

CkHttp_Dispose(http);
CkJsonObject_Dispose(json);
CkStringBuilder_Dispose(sbRequestBody);

Curl Command

curl -X GET
	-H "Authorization: Bearer <access_token>"
	-H "Accept-Language: ar"
	-d '{
    "documentTypeCodeName": "creditupdated",
    "namePrimaryLang": "CreditEn",
    "nameSecondaryLang": "CreditAr",
    "descriptionPrimaryLang": "Des-creditEn",
    "descriptionSecondaryLang": "Des-creditAr",
    "activeFrom": "2020-06-09T07:38:54.836Z"
}'
https://domain.com/api/v1/documenttypes

Postman Collection Item JSON

{
  "name": "2. Get Document Types",
  "protocolProfileBehavior": {
    "disableBodyPruning": true
  },
  "request": {
    "auth": {
      "type": "bearer",
      "bearer": [
        {
          "key": "token",
          "value": "{{generatedAccessToken}}",
          "type": "string"
        }
      ]
    },
    "method": "GET",
    "header": [
      {
        "key": "Accept-Language",
        "value": "ar",
        "type": "text"
      }
    ],
    "body": {
      "mode": "raw",
      "raw": "{\r\n    \"documentTypeCodeName\": \"creditupdated\",\r\n    \"namePrimaryLang\": \"CreditEn\",\r\n    \"nameSecondaryLang\": \"CreditAr\",\r\n    \"descriptionPrimaryLang\": \"Des-creditEn\",\r\n    \"descriptionSecondaryLang\": \"Des-creditAr\",\r\n    \"activeFrom\": \"2020-06-09T07:38:54.836Z\"\r\n}",
      "options": {
        "raw": {
          "language": "json"
        }
      }
    },
    "url": {
      "raw": "{{apiBaseUrl}}/api/v1/documenttypes",
      "host": [
        "{{apiBaseUrl}}"
      ],
      "path": [
        "api",
        "v1",
        "documenttypes"
      ]
    }
  },
  "response": [
  ]
}