Chilkat Online Tools

PureBasic / Creatio API / Get a field of object collection instance by Id

Back to Collection Items

IncludeFile "CkStringBuilder.pb"
IncludeFile "CkHttp.pb"
IncludeFile "CkXml.pb"

Procedure ChilkatExample()

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

    http.i = CkHttp::ckCreate()
    If http.i = 0
        Debug "Failed to create object."
        ProcedureReturn
    EndIf

    success.i

    CkHttp::ckSetRequestHeader(http,"ForceUseSession","true")
    CkHttp::ckSetRequestHeader(http,"BPMCSRF","{{BPMCSRF}}")

    sbResponseBody.i = CkStringBuilder::ckCreate()
    If sbResponseBody.i = 0
        Debug "Failed to create object."
        ProcedureReturn
    EndIf

    success = CkHttp::ckQuickGetSb(http,"https://myserver.com/0/ServiceModel/EntityDataService.svc/Collection1Collection(guid'Id')/Field1",sbResponseBody)
    If success = 0
        Debug CkHttp::ckLastErrorText(http)
        CkHttp::ckDispose(http)
        CkStringBuilder::ckDispose(sbResponseBody)
        ProcedureReturn
    EndIf

    xmlResponse.i = CkXml::ckCreate()
    If xmlResponse.i = 0
        Debug "Failed to create object."
        ProcedureReturn
    EndIf

    CkXml::ckLoadSb(xmlResponse,sbResponseBody,1)
    Debug CkXml::ckGetXml(xmlResponse)

    ; Sample XML response:
    ; (Sample code for parsing the XML response is shown below)

    ; <?xml version="1.0" encoding="utf-8"?>
    ; <d:Name xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">William Walker</d:Name>

    ; Sample code for parsing the XML response...
    ; Use this online tool to generate parsing code from sample XML: Generate XML Parsing Code

    d_Name_xmlns_d.s = CkXml::ckGetAttrValue(xmlResponse,"xmlns:d")
    d_Name_xmlns_m.s = CkXml::ckGetAttrValue(xmlResponse,"xmlns:m")
    d_Name.s = CkXml::ckContent(xmlResponse)


    CkHttp::ckDispose(http)
    CkStringBuilder::ckDispose(sbResponseBody)
    CkXml::ckDispose(xmlResponse)


    ProcedureReturn
EndProcedure

Curl Command

curl -X GET
	-H "ForceUseSession: true"
	-H "BPMCSRF: {{BPMCSRF}}"
https://myserver.com/0/ServiceModel/EntityDataService.svc/Collection1Collection(guid'Id')/Field1

Postman Collection Item JSON

{
  "name": "Get a field of object collection instance by Id",
  "protocolProfileBehavior": {
    "disableBodyPruning": true
  },
  "request": {
    "method": "GET",
    "header": [
      {
        "key": "ForceUseSession",
        "type": "text",
        "value": "true"
      },
      {
        "key": "BPMCSRF",
        "type": "text",
        "value": "{{BPMCSRF}}"
      }
    ],
    "body": {
      "mode": "raw",
      "raw": ""
    },
    "url": {
      "raw": "{{BaseURI}}/0/ServiceModel/EntityDataService.svc/{{CollectionName1}}Collection(guid'{{ObjectId1}}')/{{FieldName1}}",
      "host": [
        "{{BaseURI}}"
      ],
      "path": [
        "0",
        "ServiceModel",
        "EntityDataService.svc",
        "{{CollectionName1}}Collection(guid'{{ObjectId1}}')",
        "{{FieldName1}}"
      ]
    },
    "description": "Request for getting a specific field value by the Id of an object collection instance."
  },
  "response": [
    {
      "name": "[200] Gets a field of an object collection instance by Id",
      "originalRequest": {
        "method": "GET",
        "header": [
          {
            "key": "ForceUseSession",
            "type": "text",
            "value": "true"
          },
          {
            "key": "BPMCSRF",
            "type": "text",
            "value": "{{BPMCSRF}}"
          }
        ],
        "url": {
          "raw": "https://myserver.com/0/ServiceModel/EntityDataService.svc/EmployeeCollection(guid'c31c7862-fe33-4a13-9bbc-0943fa08fd02')/Name",
          "protocol": "https",
          "host": [
            "myserver",
            "com"
          ],
          "path": [
            "0",
            "ServiceModel",
            "EntityDataService.svc",
            "EmployeeCollection(guid'c31c7862-fe33-4a13-9bbc-0943fa08fd02')",
            "Name"
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "xml",
      "header": [
        {
          "key": "Cache-Control",
          "value": "no-cache"
        },
        {
          "key": "Content-Type",
          "value": "application/xml;charset=utf-8"
        },
        {
          "key": "Server",
          "value": "Microsoft-IIS/10.0"
        },
        {
          "key": "X-Content-Type-Options",
          "value": "nosniff"
        },
        {
          "key": "X-Content-Type-Options",
          "value": "nosniff"
        },
        {
          "key": "DataServiceVersion",
          "value": "1.0;"
        },
        {
          "key": "X-AspNet-Version",
          "value": "4.0.30319"
        },
        {
          "key": "X-Powered-By",
          "value": "ASP.NET"
        },
        {
          "key": "X-Frame-Options",
          "value": "SAMEORIGIN"
        },
        {
          "key": "Date",
          "value": "Thu, 09 Apr 2020 11:18:14 GMT"
        },
        {
          "key": "Content-Length",
          "value": "206"
        }
      ],
      "cookie": [
      ],
      "body": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<d:Name xmlns:d=\"http://schemas.microsoft.com/ado/2007/08/dataservices\" xmlns:m=\"http://schemas.microsoft.com/ado/2007/08/dataservices/metadata\">William Walker</d:Name>"
    }
  ]
}