Chilkat Online Tools

C / Creatio API / Modify a field of an object collection instance

Back to Collection Items

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

void ChilkatSample(void)
    {
    HCkHttp http;
    BOOL success;
    HCkBinData bdRequestBody;
    HCkHttpResponse resp;

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

    http = CkHttp_Create();

    bdRequestBody = CkBinData_Create();
    success = CkBinData_LoadFile(bdRequestBody,"scr_NewContactPhoto.png");
    if (success != TRUE) {
        printf("Failed to load scr_NewContactPhoto.png\n");
        CkHttp_Dispose(http);
        CkBinData_Dispose(bdRequestBody);
        return;
    }

    CkHttp_SetRequestHeader(http,"BPMCSRF","{{BPMCSRF}}");
    CkHttp_SetRequestHeader(http,"Accept","application/json; text/plain; */*");

    resp = CkHttp_PBinaryBd(http,"PUT","https://myserver.com/0/odata/Collection4({{FieldName6Value6}})/{{FieldName4}}",bdRequestBody,"application/octet-stream; IEEE754Compatible=true",FALSE,FALSE);
    if (CkHttp_getLastMethodSuccess(http) == FALSE) {
        printf("%s\n",CkHttp_lastErrorText(http));
        CkHttp_Dispose(http);
        CkBinData_Dispose(bdRequestBody);
        return;
    }

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


    CkHttp_Dispose(http);
    CkBinData_Dispose(bdRequestBody);

    }

Curl Command

curl -X PUT
	-H "Accept: application/json; text/plain; */*"
	-H "Content-Type: application/octet-stream; IEEE754Compatible=true"
	-H "BPMCSRF: {{BPMCSRF}}"
	--data-binary '@scr_NewContactPhoto.png'
https://myserver.com/0/odata/Collection4({{FieldName6Value6}})/{{FieldName4}}

Postman Collection Item JSON

{
  "name": "Modify a field of an object collection instance",
  "event": [
    {
      "listen": "test",
      "script": {
        "exec": [
          ""
        ],
        "type": "text/javascript"
      }
    },
    {
      "listen": "prerequest",
      "script": {
        "exec": [
          ""
        ],
        "type": "text/javascript"
      }
    }
  ],
  "request": {
    "method": "PUT",
    "header": [
      {
        "key": "Accept",
        "value": "application/json; text/plain; */*",
        "type": "text"
      },
      {
        "key": "Content-Type",
        "name": "Content-Type",
        "value": "application/octet-stream; IEEE754Compatible=true",
        "type": "text"
      },
      {
        "key": "BPMCSRF",
        "value": "{{BPMCSRF}}",
        "type": "text"
      }
    ],
    "body": {
      "mode": "file",
      "file": {
        "src": "/C:/Users/M.Kysla/Downloads/scr_NewContactPhoto.png"
      }
    },
    "url": {
      "raw": "{{BaseURI}}/0/odata/{{CollectionName4}}({{FieldName6Value6}})/{{FieldName4}}",
      "host": [
        "{{BaseURI}}"
      ],
      "path": [
        "0",
        "odata",
        "{{CollectionName4}}({{FieldName6Value6}})",
        "{{FieldName4}}"
      ]
    },
    "description": "Request for modifying a field of an object collection instance."
  },
  "response": [
    {
      "name": "[200] Modifies an object collection instance",
      "originalRequest": {
        "method": "PUT",
        "header": [
          {
            "key": "Accept",
            "value": "application/json; text/plain; */*",
            "type": "text"
          },
          {
            "key": "Content-Type",
            "name": "Content-Type",
            "value": "application/octet-stream; IEEE754Compatible=true",
            "type": "text"
          },
          {
            "key": "BPMCSRF",
            "value": "{{BPMCSRF}}",
            "type": "text"
          }
        ],
        "body": {
          "mode": "file",
          "file": {
            "src": "/C:/Users/M.Kysla/Downloads/scr_NewContactPhoto.png"
          },
          "options": {
            "raw": {
              "language": "json"
            }
          }
        },
        "url": {
          "raw": "https://myserver.com/0/odata/SysImage(410006e1-ca4e-4502-a9ec-e54d922d2c01)/Data",
          "protocol": "https",
          "host": [
            "myserver",
            "com"
          ],
          "path": [
            "0",
            "odata",
            "SysImage(410006e1-ca4e-4502-a9ec-e54d922d2c01)",
            "Data"
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "Text",
      "header": [
      ],
      "cookie": [
      ],
      "body": ""
    }
  ]
}