Back to Collection Items
#import <CkoHttp.h>
#import <CkoJsonObject.h>
#import <CkoStringBuilder.h>
#import <CkoHttpResponse.h>
#import <NSString.h>
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
CkoHttp *http = [[CkoHttp alloc] init];
BOOL success;
http.BasicAuth = YES;
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
// }
CkoJsonObject *json = [[CkoJsonObject alloc] init];
[json UpdateString: @"name" value: @"bot"];
[json UpdateString: @"integrationType" value: @"zd:agentWorkspace"];
[json UpdateBool: @"deliverStandbyEvents" value: YES];
[json UpdateString: @"nextSwitchboardIntegrationId" value: @"5ef21b86e933b7355c11c606"];
[json UpdateInt: @"messageHistoryCount" value: [NSNumber numberWithInt: 5]];
[http SetRequestHeader: @"Content-Type" value: @"application/json"];
CkoStringBuilder *sbRequestBody = [[CkoStringBuilder alloc] init];
[json EmitSb: sbRequestBody];
CkoHttpResponse *resp = [http PTextSb: @"PATCH" url: @"https://domain.com/v2/apps/{{appId}}/switchboards/:switchboardId/switchboardIntegrations/:switchboardIntegrationId" textData: sbRequestBody charset: @"utf-8" contentType: @"application/json" md5: NO gzip: NO];
if (http.LastMethodSuccess == NO) {
NSLog(@"%@",http.LastErrorText);
return;
}
CkoStringBuilder *sbResponseBody = [[CkoStringBuilder alloc] init];
[resp GetBodySb: sbResponseBody];
CkoJsonObject *jResp = [[CkoJsonObject alloc] init];
[jResp LoadSb: sbResponseBody];
jResp.EmitCompact = NO;
NSLog(@"%@",@"Response Body:");
NSLog(@"%@",[jResp Emit]);
int respStatusCode = [resp.StatusCode intValue];
NSLog(@"%@%d",@"Response Status Code = ",respStatusCode);
if (respStatusCode >= 400) {
NSLog(@"%@",@"Response Header:");
NSLog(@"%@",resp.Header);
NSLog(@"%@",@"Failed.");
return;
}
// 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
NSString *Id = [jResp StringOf: @"switchboardIntegration.id"];
NSString *Name = [jResp StringOf: @"switchboardIntegration.name"];
NSString *IntegrationId = [jResp StringOf: @"switchboardIntegration.integrationId"];
NSString *IntegrationType = [jResp StringOf: @"switchboardIntegration.integrationType"];
BOOL DeliverStandbyEvents = [jResp BoolOf: @"switchboardIntegration.deliverStandbyEvents"];
NSString *NextSwitchboardIntegrationId = [jResp StringOf: @"switchboardIntegration.nextSwitchboardIntegrationId"];
int MessageHistoryCount = [[jResp IntOf: @"switchboardIntegration.messageHistoryCount"] intValue];
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": ""
}
]
}