Chilkat Online Tools

Xojo / Sunshine Conversations API / Update Switchboard Integration

Back to Collection Items

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

Dim http As New Chilkat.Http
Dim success As Boolean

http.BasicAuth = True
http.Login = "username"
http.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.

// {
//   "name": "bot",
//   "integrationType": "zd:agentWorkspace",
//   "deliverStandbyEvents": true,
//   "nextSwitchboardIntegrationId": "5ef21b86e933b7355c11c606",
//   "messageHistoryCount": 5
// }

Dim json As New Chilkat.JsonObject
success = json.UpdateString("name","bot")
success = json.UpdateString("integrationType","zd:agentWorkspace")
success = json.UpdateBool("deliverStandbyEvents",True)
success = json.UpdateString("nextSwitchboardIntegrationId","5ef21b86e933b7355c11c606")
success = json.UpdateInt("messageHistoryCount",5)

http.SetRequestHeader "Content-Type","application/json"

Dim sbRequestBody As New Chilkat.StringBuilder
success = json.EmitSb(sbRequestBody)

Dim resp As Chilkat.HttpResponse
resp = http.PTextSb("PATCH","https://domain.com/v2/apps/{{appId}}/switchboards/:switchboardId/switchboardIntegrations/:switchboardIntegrationId",sbRequestBody,"utf-8","application/json",False,False)
If (http.LastMethodSuccess = False) Then
    System.DebugLog(http.LastErrorText)
    Return
End If

Dim sbResponseBody As New Chilkat.StringBuilder
success = resp.GetBodySb(sbResponseBody)

Dim jResp As New Chilkat.JsonObject
success = jResp.LoadSb(sbResponseBody)
jResp.EmitCompact = False

System.DebugLog("Response Body:")
System.DebugLog(jResp.Emit())

Dim respStatusCode As Int32
respStatusCode = resp.StatusCode
System.DebugLog("Response Status Code = " + Str(respStatusCode))
If (respStatusCode >= 400) Then
    System.DebugLog("Response Header:")
    System.DebugLog(resp.Header)
    System.DebugLog("Failed.")

    Return
End If

// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)

// {
//   "switchboardIntegration": {
//     "id": "5ef21b86e933b7355c11c604",
//     "name": "bot",
//     "integrationId": "5ef21b86e933b7355c11c605",
//     "integrationType": "zd:agentWorkspace",
//     "deliverStandbyEvents": true,
//     "nextSwitchboardIntegrationId": "5ef21b86e933b7355c11c606",
//     "messageHistoryCount": 5
//   }
// }

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

Dim Id As String
Id = jResp.StringOf("switchboardIntegration.id")
Dim Name As String
Name = jResp.StringOf("switchboardIntegration.name")
Dim IntegrationId As String
IntegrationId = jResp.StringOf("switchboardIntegration.integrationId")
Dim IntegrationType As String
IntegrationType = jResp.StringOf("switchboardIntegration.integrationType")
Dim DeliverStandbyEvents As Boolean
DeliverStandbyEvents = jResp.BoolOf("switchboardIntegration.deliverStandbyEvents")
Dim NextSwitchboardIntegrationId As String
NextSwitchboardIntegrationId = jResp.StringOf("switchboardIntegration.nextSwitchboardIntegrationId")
Dim MessageHistoryCount As Int32
MessageHistoryCount = jResp.IntOf("switchboardIntegration.messageHistoryCount")

Curl Command

curl -X PATCH
	-u 'username:password'
	-H "Content-Type: application/json"
	-d '{
    "name": "bot",
    "integrationType": "zd:agentWorkspace",
    "deliverStandbyEvents": true,
    "nextSwitchboardIntegrationId": "5ef21b86e933b7355c11c606",
    "messageHistoryCount": 5
}'
https://domain.com/v2/apps/{{appId}}/switchboards/:switchboardId/switchboardIntegrations/:switchboardIntegrationId

Postman Collection Item JSON

{
  "name": "Update Switchboard Integration",
  "_postman_id": "8bdfa234-93ff-4910-8436-4b820fcaeb45",
  "request": {
    "method": "PATCH",
    "header": [
      {
        "key": "Content-Type",
        "value": "application/json"
      }
    ],
    "body": {
      "mode": "raw",
      "raw": "{\n    \"name\": \"bot\",\n    \"integrationType\": \"zd:agentWorkspace\",\n    \"deliverStandbyEvents\": true,\n    \"nextSwitchboardIntegrationId\": \"5ef21b86e933b7355c11c606\",\n    \"messageHistoryCount\": 5\n}"
    },
    "url": {
      "raw": "{{url}}/v2/apps/{{appId}}/switchboards/:switchboardId/switchboardIntegrations/:switchboardIntegrationId",
      "host": [
        "{{url}}"
      ],
      "path": [
        "v2",
        "apps",
        "{{appId}}",
        "switchboards",
        ":switchboardId",
        "switchboardIntegrations",
        ":switchboardIntegrationId"
      ],
      "variable": [
        {
          "key": "switchboardId"
        },
        {
          "key": "switchboardIntegrationId"
        }
      ]
    },
    "description": "Updates a switchboard integration record."
  },
  "response": [
    {
      "id": "779da036-39be-4849-853b-49a9485ea4fe",
      "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    \"name\": \"bot\",\n    \"integrationType\": \"zd:agentWorkspace\",\n    \"deliverStandbyEvents\": true,\n    \"nextSwitchboardIntegrationId\": \"5ef21b86e933b7355c11c606\",\n    \"messageHistoryCount\": 5\n}"
        },
        "url": {
          "raw": "{{baseUrl}}/v2/apps/:appId/switchboards/:switchboardId/switchboardIntegrations/:switchboardIntegrationId",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "v2",
            "apps",
            ":appId",
            "switchboards",
            ":switchboardId",
            "switchboardIntegrations",
            ":switchboardIntegrationId"
          ],
          "variable": [
            {
              "key": "appId"
            },
            {
              "key": "switchboardId"
            },
            {
              "key": "switchboardIntegrationId"
            }
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n \"switchboardIntegration\": {\n  \"id\": \"5ef21b86e933b7355c11c604\",\n  \"name\": \"bot\",\n  \"integrationId\": \"5ef21b86e933b7355c11c605\",\n  \"integrationType\": \"zd:agentWorkspace\",\n  \"deliverStandbyEvents\": true,\n  \"nextSwitchboardIntegrationId\": \"5ef21b86e933b7355c11c606\",\n  \"messageHistoryCount\": 5\n }\n}"
    },
    {
      "id": "d52dad4e-71a0-4ab5-a58f-3568a48f608e",
      "name": "Enabled switchboard must have an associated default switchboardIntegration",
      "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    \"name\": \"bot\",\n    \"integrationType\": \"zd:agentWorkspace\",\n    \"deliverStandbyEvents\": true,\n    \"nextSwitchboardIntegrationId\": \"5ef21b86e933b7355c11c606\",\n    \"messageHistoryCount\": 5\n}"
        },
        "url": {
          "raw": "{{baseUrl}}/v2/apps/:appId/switchboards/:switchboardId/switchboardIntegrations/:switchboardIntegrationId",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "v2",
            "apps",
            ":appId",
            "switchboards",
            ":switchboardId",
            "switchboardIntegrations",
            ":switchboardIntegrationId"
          ],
          "variable": [
            {
              "key": "appId"
            },
            {
              "key": "switchboardId"
            },
            {
              "key": "switchboardIntegrationId"
            }
          ]
        }
      },
      "status": "Not Found",
      "code": 404,
      "_postman_previewlanguage": "text",
      "header": [
        {
          "key": "Content-Type",
          "value": "text/plain"
        }
      ],
      "cookie": [
      ],
      "body": ""
    }
  ]
}