Chilkat Online Tools

unicodeCpp / Coupa Postman Collection - OAuth - Master / Create Payment Term

Back to Collection Items

#include <CkHttpW.h>
#include <CkXmlW.h>
#include <CkStringBuilderW.h>
#include <CkHttpResponseW.h>

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

    CkHttpW http;
    bool success;

    // 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"?>
    // <payment-term>
    //     <code>Net 140</code>
    // </payment-term>
    // 

    CkXmlW xml;
    xml.put_Tag(L"payment-term");
    xml.UpdateChildContent(L"code",L"Net 140");

    // Adds the "Authorization: Bearer <access_token>" header.
    http.put_AuthToken(L"<access_token>");

    CkStringBuilderW sbRequestBody;
    xml.GetXmlSb(sbRequestBody);

    CkHttpResponseW *resp = http.PTextSb(L"POST",L"https://domain.com/payment_terms?fields=[\"id\",\"code\",\"description\",\"active\"]",sbRequestBody,L"utf-8",L"application/xml",false,false);
    if (http.get_LastMethodSuccess() == false) {
        wprintf(L"%s\n",http.lastErrorText());
        return;
    }

    wprintf(L"%d\n",resp->get_StatusCode());
    wprintf(L"%s\n",resp->bodyStr());
    delete resp;
    }

Curl Command

curl -X POST
	-H "Authorization: Bearer <access_token>"
	-d '<payment-term>
    <code>Net 140</code>
</payment-term>'
https://domain.com/payment_terms?fields=["id","code","description","active"]

Postman Collection Item JSON

{
  "name": "Create Payment Term",
  "request": {
    "method": "POST",
    "header": [
    ],
    "body": {
      "mode": "raw",
      "raw": "<payment-term>\n    <code>Net 140</code>\n</payment-term>",
      "options": {
        "raw": {
          "language": "xml"
        }
      }
    },
    "url": {
      "raw": "{{URL}}/payment_terms?fields=[\"id\",\"code\",\"description\",\"active\"]",
      "host": [
        "{{URL}}"
      ],
      "path": [
        "payment_terms"
      ],
      "query": [
        {
          "key": "fields",
          "value": "[\"id\",\"code\",\"description\",\"active\"]"
        }
      ]
    }
  },
  "response": [
  ]
}