Chilkat Online Tools

C++ / Creatio API / Delete a field of an object collection instance

Back to Collection Items

#include <CkHttp.h>
#include <CkHttpResponse.h>

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

    CkHttp http;
    bool success;

    http.SetRequestHeader("Content-Type","application/octet-stream; IEEE754Compatible=true");
    http.SetRequestHeader("BPMCSRF","{{BPMCSRF}}");
    http.SetRequestHeader("Accept","application/json; text/plain; */*");

    CkHttpResponse *resp = http.QuickRequest("DELETE","https://myserver.com/0/odata/Collection4(Id)/Field4");
    if (http.get_LastMethodSuccess() == false) {
        std::cout << http.lastErrorText() << "\r\n";
        return;
    }

    int respStatusCode = resp->get_StatusCode();
    std::cout << "Response Status Code = " << respStatusCode << "\r\n";
    if (respStatusCode != 204) {
        std::cout << "Response Header:" << "\r\n";
        std::cout << resp->header() << "\r\n";
        std::cout << "Response Body:" << "\r\n";
        std::cout << resp->bodyStr() << "\r\n";
        std::cout << "Failed." << "\r\n";
        delete resp;
        return;
    }

    delete resp;
    std::cout << "Success." << "\r\n";
    }

Curl Command

curl -X DELETE
	-H "Accept: application/json; text/plain; */*"
	-H "Content-Type: application/octet-stream; IEEE754Compatible=true"
	-H "BPMCSRF: {{BPMCSRF}}"
https://myserver.com/0/odata/Collection4(Id)/Field4

Postman Collection Item JSON

{
  "name": "Delete a field of an object collection instance",
  "event": [
    {
      "listen": "test",
      "script": {
        "exec": [
          ""
        ],
        "type": "text/javascript"
      }
    }
  ],
  "request": {
    "method": "DELETE",
    "header": [
      {
        "key": "Accept",
        "value": "application/json; text/plain; */*",
        "type": "text"
      },
      {
        "key": "Content-Type",
        "value": "application/octet-stream; IEEE754Compatible=true",
        "type": "text"
      },
      {
        "key": "BPMCSRF",
        "value": "{{BPMCSRF}}",
        "type": "text"
      }
    ],
    "url": {
      "raw": "{{BaseURI}}/0/odata/{{CollectionName4}}({{ObjectId2}})/{{FieldName4}}",
      "host": [
        "{{BaseURI}}"
      ],
      "path": [
        "0",
        "odata",
        "{{CollectionName4}}({{ObjectId2}})",
        "{{FieldName4}}"
      ]
    },
    "description": "Request for deleting a field of an object collection instance."
  },
  "response": [
    {
      "name": "[204] Deletes an object collection instance",
      "originalRequest": {
        "method": "DELETE",
        "header": [
          {
            "key": "Accept",
            "value": "application/json; text/plain; */*",
            "type": "text"
          },
          {
            "key": "Content-Type",
            "value": "application/octet-stream; IEEE754Compatible=true",
            "type": "text"
          },
          {
            "key": "BPMCSRF",
            "value": "{{BPMCSRF}}",
            "type": "text"
          }
        ],
        "url": {
          "raw": "https://myserver.com/0/odata/SysImage(29FE7EDF-4DB9-4E09-92B0-018047BA1F71)/Data",
          "protocol": "https",
          "host": [
            "myserver",
            "com"
          ],
          "path": [
            "0",
            "odata",
            "SysImage(29FE7EDF-4DB9-4E09-92B0-018047BA1F71)",
            "Data"
          ]
        }
      },
      "status": "No Content",
      "code": 204,
      "_postman_previewlanguage": "Text",
      "header": [
      ],
      "cookie": [
      ],
      "body": ""
    }
  ]
}