Chilkat Online Tools

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

Back to Collection Items

// Important: Don't forget to include the call to System.loadLibrary
// as shown at the bottom of this code sample.
package com.test;

import android.app.Activity;
import com.chilkatsoft.*;

import android.widget.TextView;
import android.os.Bundle;

public class SimpleActivity extends Activity {

  private static final String TAG = "Chilkat";

  // Called when the activity is first created.
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

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

    CkHttp http = new CkHttp();
    boolean success;

    CkBinData bdRequestBody = new CkBinData();
    success = bdRequestBody.LoadFile("scr_NewContactPhoto.png");
    if (success != true) {
        Log.i(TAG, "Failed to load scr_NewContactPhoto.png");
        return;
        }

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

    CkHttpResponse resp = http.PBinaryBd("PUT","https://myserver.com/0/odata/Collection4({{FieldName6Value6}})/{{FieldName4}}",bdRequestBody,"application/octet-stream; IEEE754Compatible=true",false,false);
    if (http.get_LastMethodSuccess() == false) {
        Log.i(TAG, http.lastErrorText());
        return;
        }

    Log.i(TAG, String.valueOf(resp.get_StatusCode()));
    Log.i(TAG, resp.bodyStr());


  }

  static {
      System.loadLibrary("chilkat");

      // Note: If the incorrect library name is passed to System.loadLibrary,
      // then you will see the following error message at application startup:
      //"The application <your-application-name> has stopped unexpectedly. Please try again."
  }
}

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": ""
    }
  ]
}