Back to Collection Items
LOCAL loHttp
LOCAL lnSuccess
LOCAL loJson
LOCAL loSbRequestBody
LOCAL loResp
LOCAL loSbResponseBody
LOCAL loJResp
LOCAL lnRespStatusCode
LOCAL lcId
LOCAL lcV_Type
LOCAL lcActiveSwitchboardIntegrationId
LOCAL lcName
LOCAL lcIntegrationId
LOCAL lcIntegrationType
LOCAL lcPendingSwitchboardIntegrationId
LOCAL lcPendingSwitchboardIntegrationName
LOCAL lcPendingSwitchboardIntegrationIntegrationId
LOCAL lcPendingSwitchboardIntegrationIntegrationType
LOCAL lnIsDefault
LOCAL lcDisplayName
LOCAL lcDescription
LOCAL lcIconUrl
LOCAL lcLang
LOCAL lcBusinessLastRead
LOCAL lcLastUpdatedAt
* This example assumes the Chilkat API to have been previously unlocked.
* See Global Unlock Sample for sample code.
* For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.Http')
loHttp = CreateObject('Chilkat.Http')
loHttp.BasicAuth = 1
loHttp.Login = "username"
loHttp.Password = "password"
* Use this online tool to generate code from sample JSON: Generate Code to Create JSON
* The following JSON is sent in the request body.
* {
* "displayName": "elit",
* "description": "Conversation between Rogers and Carl.",
* "iconUrl": "https://www.gravatar.com/image.jpg",
* "metadata": {
* "lang": "en-ca"
* }
* }
* For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.JsonObject')
loJson = CreateObject('Chilkat.JsonObject')
loJson.UpdateString("displayName","elit")
loJson.UpdateString("description","Conversation between Rogers and Carl.")
loJson.UpdateString("iconUrl","https://www.gravatar.com/image.jpg")
loJson.UpdateString("metadata.lang","en-ca")
loHttp.SetRequestHeader("Content-Type","application/json")
* For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.StringBuilder')
loSbRequestBody = CreateObject('Chilkat.StringBuilder')
loJson.EmitSb(loSbRequestBody)
loResp = loHttp.PTextSb("PATCH","https://domain.com/",loSbRequestBody,"utf-8","application/json",0,0)
IF (loHttp.LastMethodSuccess = 0) THEN
? loHttp.LastErrorText
RELEASE loHttp
RELEASE loJson
RELEASE loSbRequestBody
CANCEL
ENDIF
* For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.StringBuilder')
loSbResponseBody = CreateObject('Chilkat.StringBuilder')
loResp.GetBodySb(loSbResponseBody)
* For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.JsonObject')
loJResp = CreateObject('Chilkat.JsonObject')
loJResp.LoadSb(loSbResponseBody)
loJResp.EmitCompact = 0
? "Response Body:"
? loJResp.Emit()
lnRespStatusCode = loResp.StatusCode
? "Response Status Code = " + STR(lnRespStatusCode)
IF (lnRespStatusCode >= 400) THEN
? "Response Header:"
? loResp.Header
? "Failed."
RELEASE loResp
RELEASE loHttp
RELEASE loJson
RELEASE loSbRequestBody
RELEASE loSbResponseBody
RELEASE loJResp
CANCEL
ENDIF
RELEASE loResp
* Sample JSON response:
* (Sample code for parsing the JSON response is shown below)
* {
* "conversation": {
* "id": "c93bb9c14dde8ffb94564eae",
* "type": "personal",
* "activeSwitchboardIntegration": {
* "id": "5ef21b86e933b7355c11c604",
* "name": "bot",
* "integrationId": "5ef21b86e933b7355c11c605",
* "integrationType": "zd:agentWorkspace"
* },
* "pendingSwitchboardIntegration": {
* "id": "5ef21b86e933b7355c11c604",
* "name": "bot",
* "integrationId": "5ef21b86e933b7355c11c605",
* "integrationType": "zd:agentWorkspace"
* },
* "isDefault": false,
* "displayName": "pari",
* "description": "Conversation between Rogers and Carl.",
* "iconUrl": "https://www.gravatar.com/image.jpg",
* "metadata": {
* "lang": "en-ca"
* },
* "businessLastRead": "2020-06-23T14:33:47.492Z",
* "lastUpdatedAt": "2020-06-26T14:33:47.120Z"
* }
* }
* Sample code for parsing the JSON response...
* Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code
lcId = loJResp.StringOf("conversation.id")
lcV_Type = loJResp.StringOf("conversation.type")
lcActiveSwitchboardIntegrationId = loJResp.StringOf("conversation.activeSwitchboardIntegration.id")
lcName = loJResp.StringOf("conversation.activeSwitchboardIntegration.name")
lcIntegrationId = loJResp.StringOf("conversation.activeSwitchboardIntegration.integrationId")
lcIntegrationType = loJResp.StringOf("conversation.activeSwitchboardIntegration.integrationType")
lcPendingSwitchboardIntegrationId = loJResp.StringOf("conversation.pendingSwitchboardIntegration.id")
lcPendingSwitchboardIntegrationName = loJResp.StringOf("conversation.pendingSwitchboardIntegration.name")
lcPendingSwitchboardIntegrationIntegrationId = loJResp.StringOf("conversation.pendingSwitchboardIntegration.integrationId")
lcPendingSwitchboardIntegrationIntegrationType = loJResp.StringOf("conversation.pendingSwitchboardIntegration.integrationType")
lnIsDefault = loJResp.BoolOf("conversation.isDefault")
lcDisplayName = loJResp.StringOf("conversation.displayName")
lcDescription = loJResp.StringOf("conversation.description")
lcIconUrl = loJResp.StringOf("conversation.iconUrl")
lcLang = loJResp.StringOf("conversation.metadata.lang")
lcBusinessLastRead = loJResp.StringOf("conversation.businessLastRead")
lcLastUpdatedAt = loJResp.StringOf("conversation.lastUpdatedAt")
RELEASE loHttp
RELEASE loJson
RELEASE loSbRequestBody
RELEASE loSbResponseBody
RELEASE loJResp
Curl Command
curl -X PATCH
-u 'username:password'
-H "Content-Type: application/json"
-d '{
"displayName": "elit",
"description": "Conversation between Rogers and Carl.",
"iconUrl": "https://www.gravatar.com/image.jpg",
"metadata": {
"lang": "en-ca"
}
}'
https://domain.com/
Postman Collection Item JSON
{
"name": "Update Conversation",
"_postman_id": "96737822-d414-42cf-a54c-b19311a3b68d",
"request": {
"method": "PATCH",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"displayName\": \"elit\",\n \"description\": \"Conversation between Rogers and Carl.\",\n \"iconUrl\": \"https://www.gravatar.com/image.jpg\",\n \"metadata\": {\n \"lang\": \"en-ca\"\n }\n}"
},
"url": "{{url}}/v2/apps/{{appId}}/conversations/{{conversationId}}",
"description": "Updates a conversation record."
},
"response": [
{
"id": "f49e0f88-7c9f-4500-951a-95341d87cbb5",
"name": "Ok",
"originalRequest": {
"method": "PATCH",
"header": [
{
"description": {
"content": "Added as a part of security scheme: bearer",
"type": "text/plain"
},
"key": "Authorization",
"value": "Bearer <token>"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"displayName\": \"elit\",\n \"description\": \"Conversation between Rogers and Carl.\",\n \"iconUrl\": \"https://www.gravatar.com/image.jpg\",\n \"metadata\": {\n \"lang\": \"en-ca\"\n }\n}"
},
"url": {
"raw": "{{baseUrl}}/v2/apps/:appId/conversations/:conversationId",
"host": [
"{{baseUrl}}"
],
"path": [
"v2",
"apps",
":appId",
"conversations",
":conversationId"
],
"variable": [
{
"key": "appId"
},
{
"key": "conversationId"
}
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"conversation\": {\n \"id\": \"c93bb9c14dde8ffb94564eae\",\n \"type\": \"personal\",\n \"activeSwitchboardIntegration\": {\n \"id\": \"5ef21b86e933b7355c11c604\",\n \"name\": \"bot\",\n \"integrationId\": \"5ef21b86e933b7355c11c605\",\n \"integrationType\": \"zd:agentWorkspace\"\n },\n \"pendingSwitchboardIntegration\": {\n \"id\": \"5ef21b86e933b7355c11c604\",\n \"name\": \"bot\",\n \"integrationId\": \"5ef21b86e933b7355c11c605\",\n \"integrationType\": \"zd:agentWorkspace\"\n },\n \"isDefault\": false,\n \"displayName\": \"pari\",\n \"description\": \"Conversation between Rogers and Carl.\",\n \"iconUrl\": \"https://www.gravatar.com/image.jpg\",\n \"metadata\": {\n \"lang\": \"en-ca\"\n },\n \"businessLastRead\": \"2020-06-23T14:33:47.492Z\",\n \"lastUpdatedAt\": \"2020-06-26T14:33:47.120Z\"\n }\n}"
},
{
"id": "ffbec026-9563-44d8-afb5-d5aaa54230b9",
"name": "Conversation not found",
"originalRequest": {
"method": "PATCH",
"header": [
{
"description": {
"content": "Added as a part of security scheme: bearer",
"type": "text/plain"
},
"key": "Authorization",
"value": "Bearer <token>"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"displayName\": \"elit\",\n \"description\": \"Conversation between Rogers and Carl.\",\n \"iconUrl\": \"https://www.gravatar.com/image.jpg\",\n \"metadata\": {\n \"lang\": \"en-ca\"\n }\n}"
},
"url": {
"raw": "{{baseUrl}}/v2/apps/:appId/conversations/:conversationId",
"host": [
"{{baseUrl}}"
],
"path": [
"v2",
"apps",
":appId",
"conversations",
":conversationId"
],
"variable": [
{
"key": "appId"
},
{
"key": "conversationId"
}
]
}
},
"status": "Not Found",
"code": 404,
"_postman_previewlanguage": "text",
"header": [
{
"key": "Content-Type",
"value": "text/plain"
}
],
"cookie": [
],
"body": ""
}
]
}