Chilkat Online Tools

TCL / Creatio API / Modify object collection instance

Back to Collection Items

load ./chilkat.dll

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

set http [new_CkHttp]

# Use this online tool to generate code from sample JSON: Generate Code to Create JSON

# The following JSON is sent in the request body.

# {
#   "{{FieldName5}}": "{{FieldName5Value2}}"
# }

set json [new_CkJsonObject]

CkJsonObject_UpdateString $json "{{FieldName5}}" "{{FieldName5Value2}}"

CkHttp_SetRequestHeader $http "Content-Type" "application/json; odata=verbose"
CkHttp_SetRequestHeader $http "ForceUseSession" "true"
CkHttp_SetRequestHeader $http "BPMCSRF" "{{BPMCSRF}}"
CkHttp_SetRequestHeader $http "Accept" "application/json; odata=verbose"

set sbRequestBody [new_CkStringBuilder]

CkJsonObject_EmitSb $json $sbRequestBody

# resp is a CkHttpResponse
set resp [CkHttp_PTextSb $http "PATCH" "https://myserver.com/0/ServiceModel/EntityDataService.svc/Collection3Collection(guid'Id')" $sbRequestBody "utf-8" "application/json; odata=verbose" 0 0]
if {[CkHttp_get_LastMethodSuccess $http] == 0} then {
    puts [CkHttp_lastErrorText $http]
    delete_CkHttp $http
    delete_CkJsonObject $json
    delete_CkStringBuilder $sbRequestBody
    exit
}

set respStatusCode [CkHttpResponse_get_StatusCode $resp]
puts "Response Status Code = $respStatusCode"
if {$respStatusCode != 204} then {
    puts "Response Header:"
    puts [CkHttpResponse_header $resp]
    puts "Response Body:"
    puts [CkHttpResponse_bodyStr $resp]
    puts "Failed."
    delete_CkHttpResponse $resp

    delete_CkHttp $http
    delete_CkJsonObject $json
    delete_CkStringBuilder $sbRequestBody
    exit
}

delete_CkHttpResponse $resp

puts "Success."

delete_CkHttp $http
delete_CkJsonObject $json
delete_CkStringBuilder $sbRequestBody

Curl Command

curl -X PATCH
	-H "Accept: application/json; odata=verbose"
	-H "Content-Type: application/json; odata=verbose"
	-H "ForceUseSession: true"
	-H "BPMCSRF: {{BPMCSRF}}"
	-d '{
    "{{FieldName5}}": "{{FieldName5Value2}}"
}'
https://myserver.com/0/ServiceModel/EntityDataService.svc/Collection3Collection(guid'Id')

Postman Collection Item JSON

{
  "name": "Modify object collection instance",
  "event": [
    {
      "listen": "test",
      "script": {
        "exec": [
          ""
        ],
        "type": "text/javascript"
      }
    },
    {
      "listen": "prerequest",
      "script": {
        "exec": [
          ""
        ],
        "type": "text/javascript"
      }
    }
  ],
  "request": {
    "method": "PATCH",
    "header": [
      {
        "key": "Accept",
        "value": "application/json; odata=verbose",
        "type": "text"
      },
      {
        "key": "Content-Type",
        "name": "Content-Type",
        "value": "application/json; odata=verbose",
        "type": "text"
      },
      {
        "key": "ForceUseSession",
        "value": "true",
        "type": "text"
      },
      {
        "key": "BPMCSRF",
        "value": "{{BPMCSRF}}",
        "type": "text"
      }
    ],
    "body": {
      "mode": "raw",
      "raw": "{\n    \"{{FieldName5}}\": \"{{FieldName5Value2}}\"\n}",
      "options": {
        "raw": {
          "language": "json"
        }
      }
    },
    "url": {
      "raw": "{{BaseURI}}/0/ServiceModel/EntityDataService.svc/{{CollectionName3}}Collection(guid'{{ObjectId3}}')",
      "host": [
        "{{BaseURI}}"
      ],
      "path": [
        "0",
        "ServiceModel",
        "EntityDataService.svc",
        "{{CollectionName3}}Collection(guid'{{ObjectId3}}')"
      ]
    },
    "description": "Request for modifying an object collection instance."
  },
  "response": [
    {
      "name": "[204] Modifies an object collection instance",
      "originalRequest": {
        "method": "PATCH",
        "header": [
          {
            "key": "Accept",
            "value": "application/json; odata=verbose",
            "type": "text"
          },
          {
            "key": "Content-Type",
            "name": "Content-Type",
            "value": "application/json; odata=verbose",
            "type": "text"
          },
          {
            "key": "ForceUseSession",
            "value": "true",
            "type": "text"
          },
          {
            "key": "BPMCSRF",
            "value": "{{BPMCSRF}}",
            "type": "text"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n    \"JobTitle\": \"Head of department\"\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        },
        "url": {
          "raw": "https://myserver.com/0/ServiceModel/EntityDataService.svc/ContactCollection(guid'c31c7862-fe33-4a13-9bbc-0943fa08fd02')",
          "protocol": "https",
          "host": [
            "myserver",
            "com"
          ],
          "path": [
            "0",
            "ServiceModel",
            "EntityDataService.svc",
            "ContactCollection(guid'c31c7862-fe33-4a13-9bbc-0943fa08fd02')"
          ]
        }
      },
      "status": "No Content",
      "code": 204,
      "_postman_previewlanguage": "xml",
      "header": [
        {
          "key": "Cache-Control",
          "value": "private"
        },
        {
          "key": "Content-Type",
          "value": "text/html; charset=utf-8"
        },
        {
          "key": "Server",
          "value": "Microsoft-IIS/10.0"
        },
        {
          "key": "X-Powered-By",
          "value": "ASP.NET"
        },
        {
          "key": "X-Frame-Options",
          "value": "SAMEORIGIN"
        },
        {
          "key": "X-Content-Type-Options",
          "value": "nosniff"
        },
        {
          "key": "Date",
          "value": "Thu, 09 Apr 2020 11:32:54 GMT"
        },
        {
          "key": "Content-Length",
          "value": "5012"
        }
      ],
      "cookie": [
      ],
      "body": ""
    }
  ]
}