Chilkat Online Tools

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

Back to Collection Items

Dim fso, outFile
Set fso = CreateObject("Scripting.FileSystemObject")
Set outFile = fso.CreateTextFile("output.txt", True)

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

set http = CreateObject("Chilkat_9_5_0.Http")

set bdRequestBody = CreateObject("Chilkat_9_5_0.BinData")
success = bdRequestBody.LoadFile("scr_NewContactPhoto.png")
If (success <> 1) Then
    outFile.WriteLine("Failed to load scr_NewContactPhoto.png")
    WScript.Quit
End If

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

' resp is a Chilkat_9_5_0.HttpResponse
Set resp = http.PBinaryBd("PUT","https://myserver.com/0/odata/Collection4(Id)/Field4",bdRequestBody,"application/octet-stream; IEEE754Compatible=true",0,0)
If (http.LastMethodSuccess = 0) Then
    outFile.WriteLine(http.LastErrorText)
    WScript.Quit
End If

outFile.WriteLine(resp.StatusCode)
outFile.WriteLine(resp.BodyStr)


outFile.Close

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(Id)/Field4

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": "scr_NewContactPhoto.png"
      }
    },
    "url": {
      "raw": "{{BaseURI}}/0/odata/{{CollectionName4}}({{ObjectId2}})/{{FieldName4}}",
      "host": [
        "{{BaseURI}}"
      ],
      "path": [
        "0",
        "odata",
        "{{CollectionName4}}({{ObjectId2}})",
        "{{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": "scr_NewContactPhoto.png"
          },
          "options": {
            "raw": {
              "language": "json"
            }
          }
        },
        "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": "OK",
      "code": 200,
      "_postman_previewlanguage": "Text",
      "header": [
      ],
      "cookie": [
      ],
      "body": ""
    }
  ]
}