Back to Collection Items
var
http: HCkHttp;
success: Boolean;
xml: HCkXml;
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 XML: Generate Code to Create XML
// The following XML is sent in the request body.
// <?xml version="1.0" encoding="utf-8"?>
// <inventory-transaction>
// <quantity type="decimal">1.0</quantity>
// <type>ReceivingQuantityConsumption</type>
// <order-line>
// <id type="integer">7009</id>
// <order-header-id type="integer">5247</order-header-id>
// </order-line>
// </inventory-transaction>
//
xml := CkXml_Create();
CkXml_putTag(xml,'inventory-transaction');
CkXml_UpdateAttrAt(xml,'quantity',True,'type','decimal');
CkXml_UpdateChildContent(xml,'quantity','1.0');
CkXml_UpdateChildContent(xml,'type','ReceivingQuantityConsumption');
CkXml_UpdateAttrAt(xml,'order-line|id',True,'type','integer');
CkXml_UpdateChildContentInt(xml,'order-line|id',7009);
CkXml_UpdateAttrAt(xml,'order-line|order-header-id',True,'type','integer');
CkXml_UpdateChildContentInt(xml,'order-line|order-header-id',5247);
// Adds the "Authorization: Bearer <access_token>" header.
CkHttp_putAuthToken(http,'<access_token>');
sbRequestBody := CkStringBuilder_Create();
CkXml_GetXmlSb(xml,sbRequestBody);
resp := CkHttp_PTextSb(http,'POST','https://domain.com/receiving_transactions?fields=["id"]',sbRequestBody,'utf-8','application/xml',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);
CkXml_Dispose(xml);
CkStringBuilder_Dispose(sbRequestBody);
Curl Command
curl -X POST
-H "Authorization: Bearer <access_token>"
-d '<inventory-transaction>
<quantity type="decimal">1.0</quantity>
<type>ReceivingQuantityConsumption</type>
<order-line>
<id type="integer">7009</id>
<order-header-id type="integer">5247</order-header-id>
</order-line>
</inventory-transaction>'
https://domain.com/receiving_transactions?fields=["id"]
Postman Collection Item JSON
{
"name": "Create a new goods receipt",
"protocolProfileBehavior": {
"disabledSystemHeaders": {}
},
"request": {
"method": "POST",
"header": [
],
"body": {
"mode": "raw",
"raw": "<inventory-transaction>\r\n <quantity type=\"decimal\">1.0</quantity>\r\n <type>ReceivingQuantityConsumption</type>\r\n <order-line>\r\n <id type=\"integer\">7009</id>\r\n <order-header-id type=\"integer\">5247</order-header-id>\r\n </order-line>\r\n</inventory-transaction>",
"options": {
"raw": {
"language": "xml"
}
}
},
"url": {
"raw": "{{URL}}/receiving_transactions?fields=[\"id\"]",
"host": [
"{{URL}}"
],
"path": [
"receiving_transactions"
],
"query": [
{
"key": "fields",
"value": "[\"id\"]"
}
]
}
},
"response": [
]
}