Chilkat Online Tools

DataFlex / ORACLE Hospitality OPERA Cloud REST API Workflows / Update the guest profile with new contact details

Back to Collection Items

Use ChilkatAx-win32.pkg

Procedure Test
    Handle hoHttp
    Boolean iSuccess
    Handle hoJson
    Variant vSbRequestBody
    Handle hoSbRequestBody
    Variant vResp
    Handle hoResp
    String sTemp1
    Integer iTemp1
    Boolean bTemp1

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

    Get Create (RefClass(cComChilkatHttp)) To hoHttp
    If (Not(IsComObjectCreated(hoHttp))) Begin
        Send CreateComObject of hoHttp
    End

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

    // The following JSON is sent in the request body.

    // {
    //   "profileDetails": {
    //     "addresses": {
    //       "addressInfo": [
    //         {
    //           "address": {
    //             "addressLine": [
    //               "2640 Golden Gate Parkway",
    //               "Suite 300",
    //               "",
    //               ""
    //             ],
    //             "cityName": "Naples",
    //             "postalCode": "34105",
    //             "state": "FL",
    //             "language": "E",
    //             "type": "HOME",
    //             "typeDescription": "Home Address",
    //             "primaryInd": true
    //           }
    //         }
    //       ]
    //     },
    //     "telephones": {
    //       "telephoneInfo": [
    //         {
    //           "telephone": {
    //             "phoneTechType": "PHONE",
    //             "phoneUseType": "MOBILE",
    //             "phoneUseTypeDescription": "Mobile Phone Number",
    //             "phoneNumber": "+1 415 555 0101",
    //             "primaryInd": true,
    //             "orderSequence": "1"
    //           }
    //         }
    //       ]
    //     },
    //     "statusCode": "ACTIVE",
    //     "markForHistory": false,
    //     "hasCommission": false
    //   }
    // }

    Get Create (RefClass(cComChilkatJsonObject)) To hoJson
    If (Not(IsComObjectCreated(hoJson))) Begin
        Send CreateComObject of hoJson
    End
    Get ComUpdateString Of hoJson "profileDetails.addresses.addressInfo[0].address.addressLine[0]" "2640 Golden Gate Parkway" To iSuccess
    Get ComUpdateString Of hoJson "profileDetails.addresses.addressInfo[0].address.addressLine[1]" "Suite 300" To iSuccess
    Get ComUpdateString Of hoJson "profileDetails.addresses.addressInfo[0].address.addressLine[2]" "" To iSuccess
    Get ComUpdateString Of hoJson "profileDetails.addresses.addressInfo[0].address.addressLine[3]" "" To iSuccess
    Get ComUpdateString Of hoJson "profileDetails.addresses.addressInfo[0].address.cityName" "Naples" To iSuccess
    Get ComUpdateString Of hoJson "profileDetails.addresses.addressInfo[0].address.postalCode" "34105" To iSuccess
    Get ComUpdateString Of hoJson "profileDetails.addresses.addressInfo[0].address.state" "FL" To iSuccess
    Get ComUpdateString Of hoJson "profileDetails.addresses.addressInfo[0].address.language" "E" To iSuccess
    Get ComUpdateString Of hoJson "profileDetails.addresses.addressInfo[0].address.type" "HOME" To iSuccess
    Get ComUpdateString Of hoJson "profileDetails.addresses.addressInfo[0].address.typeDescription" "Home Address" To iSuccess
    Get ComUpdateBool Of hoJson "profileDetails.addresses.addressInfo[0].address.primaryInd" True To iSuccess
    Get ComUpdateString Of hoJson "profileDetails.telephones.telephoneInfo[0].telephone.phoneTechType" "PHONE" To iSuccess
    Get ComUpdateString Of hoJson "profileDetails.telephones.telephoneInfo[0].telephone.phoneUseType" "MOBILE" To iSuccess
    Get ComUpdateString Of hoJson "profileDetails.telephones.telephoneInfo[0].telephone.phoneUseTypeDescription" "Mobile Phone Number" To iSuccess
    Get ComUpdateString Of hoJson "profileDetails.telephones.telephoneInfo[0].telephone.phoneNumber" "+1 415 555 0101" To iSuccess
    Get ComUpdateBool Of hoJson "profileDetails.telephones.telephoneInfo[0].telephone.primaryInd" True To iSuccess
    Get ComUpdateString Of hoJson "profileDetails.telephones.telephoneInfo[0].telephone.orderSequence" "1" To iSuccess
    Get ComUpdateString Of hoJson "profileDetails.statusCode" "ACTIVE" To iSuccess
    Get ComUpdateBool Of hoJson "profileDetails.markForHistory" False To iSuccess
    Get ComUpdateBool Of hoJson "profileDetails.hasCommission" False To iSuccess

    Send ComSetRequestHeader To hoHttp "Content-Type" "application/json"
    Send ComSetRequestHeader To hoHttp "x-app-key" "{{AppKey}}"
    Send ComSetRequestHeader To hoHttp "x-hotelid" "{{HotelId}}"
    // Adds the "Authorization: Bearer <access_token>" header.
    Set ComAuthToken Of hoHttp To "<access_token>"

    Get Create (RefClass(cComChilkatStringBuilder)) To hoSbRequestBody
    If (Not(IsComObjectCreated(hoSbRequestBody))) Begin
        Send CreateComObject of hoSbRequestBody
    End
    Get pvComObject of hoSbRequestBody to vSbRequestBody
    Get ComEmitSb Of hoJson vSbRequestBody To iSuccess

    Get pvComObject of hoSbRequestBody to vSbRequestBody
    Get ComPTextSb Of hoHttp "PUT" "https://domain.com/crm/v1/profiles/{{ProfileId}}" vSbRequestBody "utf-8" "application/json" False False To vResp
    If (IsComObject(vResp)) Begin
        Get Create (RefClass(cComChilkatHttpResponse)) To hoResp
        Set pvComObject Of hoResp To vResp
    End
    Get ComLastMethodSuccess Of hoHttp To bTemp1
    If (bTemp1 = False) Begin
        Get ComLastErrorText Of hoHttp To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get ComStatusCode Of hoResp To iTemp1
    Showln iTemp1
    Get ComBodyStr Of hoResp To sTemp1
    Showln sTemp1
    Send Destroy of hoResp


End_Procedure

Curl Command

curl -X PUT
	-H "Authorization: Bearer <access_token>"
	-H "Content-Type: application/json"
	-H "x-app-key: {{AppKey}}"
	-H "x-hotelid: {{HotelId}}"
	-d '{
  "profileDetails": {
    "addresses": {
      "addressInfo": [
        {
          "address": {
            "addressLine": [
              "2640 Golden Gate Parkway",
              "Suite 300",
              "",
              ""
            ],
            "cityName": "Naples",
            "postalCode": "34105",
            "state": "FL",
            "language": "E",
            "type": "HOME",
            "typeDescription": "Home Address",
            "primaryInd": true
          }
        }
      ]
    },
    "telephones": {
      "telephoneInfo": [
        {
          "telephone": {
            "phoneTechType": "PHONE",
            "phoneUseType": "MOBILE",
            "phoneUseTypeDescription": "Mobile Phone Number",
            "phoneNumber": "+1 415 555 0101",
            "primaryInd": true,
            "orderSequence": "1"
          }
        }
      ]
    },
    "statusCode": "ACTIVE",
    "markForHistory": false,
    "hasCommission": false
  }
}'
https://domain.com/crm/v1/profiles/{{ProfileId}}

Postman Collection Item JSON

{
  "name": "Update the guest profile with new contact details",
  "request": {
    "auth": {
      "type": "bearer",
      "bearer": [
        {
          "key": "token",
          "value": "{{Token}}",
          "type": "string"
        }
      ]
    },
    "method": "PUT",
    "header": [
      {
        "key": "Content-Type",
        "name": "Content-Type",
        "value": "application/json",
        "type": "text"
      },
      {
        "key": "x-app-key",
        "value": "{{AppKey}}",
        "type": "text"
      },
      {
        "key": "x-hotelid",
        "value": "{{HotelId}}",
        "type": "text"
      }
    ],
    "body": {
      "mode": "raw",
      "raw": "{\n  \"profileDetails\": {\n    \"addresses\": {\n      \"addressInfo\": [\n        {\n          \"address\": {\n            \"addressLine\": [\n              \"2640 Golden Gate Parkway\",\n              \"Suite 300\",\n              \"\",\n              \"\"\n            ],\n            \"cityName\": \"Naples\",\n            \"postalCode\": \"34105\",\n            \"state\": \"FL\",\n            \"language\": \"E\",\n            \"type\": \"HOME\",\n            \"typeDescription\": \"Home Address\",\n            \"primaryInd\": true\n          }\n        }\n      ]\n    },\n    \"telephones\": {\n      \"telephoneInfo\": [\n        {\n          \"telephone\": {\n            \"phoneTechType\": \"PHONE\",\n            \"phoneUseType\": \"MOBILE\",\n            \"phoneUseTypeDescription\": \"Mobile Phone Number\",\n            \"phoneNumber\": \"+1 415 555 0101\",\n            \"primaryInd\": true,\n            \"orderSequence\": \"1\"\n          }\n        }\n      ]\n    },\n    \"statusCode\": \"ACTIVE\",\n    \"markForHistory\": false,\n    \"hasCommission\": false\n  }\n}",
      "options": {
        "raw": {
          "language": "json"
        }
      }
    },
    "url": {
      "raw": "{{HostName}}/crm/v1/profiles/{{ProfileId}}",
      "host": [
        "{{HostName}}"
      ],
      "path": [
        "crm",
        "v1",
        "profiles",
        "{{ProfileId}}"
      ]
    }
  },
  "response": [
  ]
}