Chilkat Online Tools

lianja / Creatio API / Add object collection instance

Back to Collection Items

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

loHttp = createobject("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.

// {
//   "{{FieldName1}}": "{{FieldName1Value3}}"
// }

loJson = createobject("CkJsonObject")
loJson.UpdateString("{{FieldName1}}","{{FieldName1Value3}}")

loHttp.SetRequestHeader("Content-Type","application/json; odata=verbose; IEEE754Compatible=true")
loHttp.SetRequestHeader("BPMCSRF","{{BPMCSRF}}")
loHttp.SetRequestHeader("Accept","application/json; odata=verbose")

loResp = loHttp.PostJson3("https://myserver.com/0/odata/Collection3","application/json; odata=verbose; IEEE754Compatible=true",loJson)
if (loHttp.LastMethodSuccess = .F.) then
    ? loHttp.LastErrorText
    release loHttp
    release loJson
    return
endif

? str(loResp.StatusCode)
? loResp.BodyStr
release loResp


release loHttp
release loJson

Curl Command

curl -X POST
	-H "Accept: application/json; odata=verbose"
	-H "Content-Type: application/json; odata=verbose; IEEE754Compatible=true"
	-H "BPMCSRF: {{BPMCSRF}}"
	-d '{
    "{{FieldName1}}": "{{FieldName1Value3}}"
}'
https://myserver.com/0/odata/Collection3

Postman Collection Item JSON

{
  "name": "Add object collection instance",
  "event": [
    {
      "listen": "test",
      "script": {
        "exec": [
          ""
        ],
        "type": "text/javascript"
      }
    },
    {
      "listen": "prerequest",
      "script": {
        "exec": [
          ""
        ],
        "type": "text/javascript"
      }
    }
  ],
  "request": {
    "method": "POST",
    "header": [
      {
        "key": "Accept",
        "value": "application/json; odata=verbose",
        "type": "text"
      },
      {
        "key": "Content-Type",
        "name": "Content-Type",
        "value": "application/json; odata=verbose; IEEE754Compatible=true",
        "type": "text"
      },
      {
        "key": "BPMCSRF",
        "value": "{{BPMCSRF}}",
        "type": "text"
      }
    ],
    "body": {
      "mode": "raw",
      "raw": "{\n    \"{{FieldName1}}\": \"{{FieldName1Value3}}\"\n}",
      "options": {
        "raw": {
          "language": "json"
        }
      }
    },
    "url": {
      "raw": "{{BaseURI}}/0/odata/{{CollectionName3}}",
      "host": [
        "{{BaseURI}}"
      ],
      "path": [
        "0",
        "odata",
        "{{CollectionName3}}"
      ]
    },
    "description": "Request for adding an object collection instance."
  },
  "response": [
    {
      "name": "[201] Adds an object collection instance",
      "originalRequest": {
        "method": "POST",
        "header": [
          {
            "key": "Accept",
            "value": "application/json; odata=verbose",
            "type": "text"
          },
          {
            "key": "Content-Type",
            "name": "Content-Type",
            "value": "application/json; odata=verbose; IEEE754Compatible=true",
            "type": "text"
          },
          {
            "key": "BPMCSRF",
            "value": "{{BPMCSRF}}",
            "type": "text"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n    \"Name\": \"New user\"\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        },
        "url": {
          "raw": "https://myserver.com/0/odata/Contact",
          "protocol": "https",
          "host": [
            "myserver",
            "com"
          ],
          "path": [
            "0",
            "odata",
            "Contact"
          ]
        }
      },
      "status": "Created",
      "code": 201,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Cache-Control",
          "value": "private"
        },
        {
          "key": "Content-Type",
          "value": "text/html; charset=utf-8"
        },
        {
          "key": "Server",
          "value": "Microsoft-IIS/10.0"
        },
        {
          "key": "Set-Cookie",
          "value": ".ASPXAUTH=66EFC86548FA6369546D9D4ADF6ED9990C53E405E9C1150A87C3F9B6CFC37B1DB0FC39FE110AF111A5B10B81C69563797DB518E8CF1F560B2F1C10E1D7E1EC7CBC538FE8CBD6F914741204BE5D7870B7F84EF3F156F8B6A76360EA1A7300354EA6CB2A5EB32EC9D49F130B0BB890305C82C375721048BC2F5D6220E89FE29B1423DA1BC4E62C30110AA0294ED9E4D5FCCE70E1A29EBA169F4519B58C583C308E377D6F0013391E54CF4E5D1934DF61E84067AC1EE251B58CD1F7B5A8D6066EAF56FE4E913D16A7E26934F4C88A95F6623545925780441F6B06C258C3E17AFFDF4F2DDF5C4075231860DD4778A15A149A791FE50B455F7E9DF22A95A6A7AB079CC4DD51AA01D7FE875A05AABB721627ED3B61277F4E5B4C5B363FA9288EF769E8F54424642743442C369EC67AC4A0345A83AB4A7FAAFDA2AE05B353FC1E2DFD8AA00312131A86C5A432BD0B5A0E77EEE1BAF9F5815F72614BE4CEBF7F12114F7D35657643; path=/; HttpOnly; SameSite=Lax"
        },
        {
          "key": "X-Powered-By",
          "value": "ASP.NET"
        },
        {
          "key": "X-Frame-Options",
          "value": "SAMEORIGIN"
        },
        {
          "key": "X-Content-Type-Options",
          "value": "nosniff"
        },
        {
          "key": "Date",
          "value": "Fri, 06 Mar 2020 07:01:22 GMT"
        },
        {
          "key": "Content-Length",
          "value": "4873"
        }
      ],
      "cookie": [
      ],
      "body": "{\n    \"@odata.context\": \"http://myserver.com/0/odata/$metadata#Contact/$entity\",\n    \"Id\": \"4c63c8fa-467b-48a6-973f-b2069298404f\",\n    \"Name\": \"New user\",\n    \"OwnerId\": \"410006e1-ca4e-4502-a9ec-e54d922d2c00\",\n    \"CreatedOn\": \"2021-01-14T08:33:29.009023Z\",\n    \"CreatedById\": \"410006e1-ca4e-4502-a9ec-e54d922d2c00\",\n    \"ModifiedOn\": \"2021-01-14T08:33:29.009023Z\",\n    \"ModifiedById\": \"410006e1-ca4e-4502-a9ec-e54d922d2c00\",\n    \"ProcessListeners\": 0,\n    \"Dear\": \"\",\n    \"SalutationTypeId\": \"00000000-0000-0000-0000-000000000000\",\n    \"GenderId\": \"00000000-0000-0000-0000-000000000000\",\n    \"AccountId\": \"00000000-0000-0000-0000-000000000000\",\n    \"DecisionRoleId\": \"00000000-0000-0000-0000-000000000000\",\n    \"TypeId\": \"00000000-0000-0000-0000-000000000000\",\n    \"JobId\": \"00000000-0000-0000-0000-000000000000\",\n    \"JobTitle\": \"\",\n    \"DepartmentId\": \"00000000-0000-0000-0000-000000000000\",\n    \"BirthDate\": \"0001-01-01T00:00:00Z\",\n    \"Phone\": \"\",\n    \"MobilePhone\": \"\",\n    \"HomePhone\": \"\",\n    \"Skype\": \"\",\n    \"Email\": \"\",\n    \"AddressTypeId\": \"00000000-0000-0000-0000-000000000000\",\n    \"Address\": \"\",\n    \"CityId\": \"00000000-0000-0000-0000-000000000000\",\n    \"RegionId\": \"00000000-0000-0000-0000-000000000000\",\n    \"Zip\": \"\",\n    \"CountryId\": \"00000000-0000-0000-0000-000000000000\",\n    \"DoNotUseEmail\": false,\n    \"DoNotUseCall\": false,\n    \"DoNotUseFax\": false,\n    \"DoNotUseSms\": false,\n    \"DoNotUseMail\": false,\n    \"Notes\": \"\",\n    \"Facebook\": \"\",\n    \"LinkedIn\": \"\",\n    \"Twitter\": \"\",\n    \"FacebookId\": \"\",\n    \"LinkedInId\": \"\",\n    \"TwitterId\": \"\",\n    \"ContactPhoto@odata.mediaEditLink\": \"Contact(4c63c8fa-467b-48a6-973f-b2069298404f)/ContactPhoto\",\n    \"ContactPhoto@odata.mediaReadLink\": \"Contact(4c63c8fa-467b-48a6-973f-b2069298404f)/ContactPhoto\",\n    \"ContactPhoto@odata.mediaContentType\": \"application/octet-stream\",\n    \"TwitterAFDAId\": \"00000000-0000-0000-0000-000000000000\",\n    \"FacebookAFDAId\": \"00000000-0000-0000-0000-000000000000\",\n    \"LinkedInAFDAId\": \"00000000-0000-0000-0000-000000000000\",\n    \"PhotoId\": \"00000000-0000-0000-0000-000000000000\",\n    \"GPSN\": \"\",\n    \"GPSE\": \"\",\n    \"Surname\": \"user\",\n    \"GivenName\": \"New\",\n    \"MiddleName\": \"\",\n    \"Confirmed\": true,\n    \"IsNonActualEmail\": false,\n    \"Completeness\": 0,\n    \"LanguageId\": \"6ebc31fa-ee6c-48e9-81bf-8003ac03b019\",\n    \"Age\": 0\n}"
    }
  ]
}