Chilkat Online Tools

Objective-C / Sunshine Conversations API / Remove Client

Back to Collection Items

#import <CkoHttp.h>
#import <CkoHttpResponse.h>
#import <CkoStringBuilder.h>
#import <CkoJsonObject.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";

CkoHttpResponse *resp = [http QuickRequest: @"DELETE" url: @"https://domain.com/v2/apps/{{appId}}/users/:userIdOrExternalId/clients/:clientId"];
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;
}

Curl Command

curl -X DELETE
	-u 'username:password'
https://domain.com/v2/apps/{{appId}}/users/:userIdOrExternalId/clients/:clientId

Postman Collection Item JSON

{
  "name": "Remove Client",
  "_postman_id": "ab865918-1a48-4b0b-96b9-e26c4a3354f9",
  "request": {
    "method": "DELETE",
    "header": [
    ],
    "url": {
      "raw": "{{url}}/v2/apps/{{appId}}/users/:userIdOrExternalId/clients/:clientId",
      "host": [
        "{{url}}"
      ],
      "path": [
        "v2",
        "apps",
        "{{appId}}",
        "users",
        ":userIdOrExternalId",
        "clients",
        ":clientId"
      ],
      "variable": [
        {
          "key": "userIdOrExternalId"
        },
        {
          "key": "clientId"
        }
      ]
    },
    "description": "Remove a particular client and unsubscribe it from all connected conversations."
  },
  "response": [
    {
      "id": "3b42b88b-22e4-4251-a1f8-62268ce9c437",
      "name": "Ok",
      "originalRequest": {
        "method": "DELETE",
        "header": [
          {
            "description": {
              "content": "Added as a part of security scheme: bearer",
              "type": "text/plain"
            },
            "key": "Authorization",
            "value": "Bearer <token>"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/v2/apps/:appId/users/:userIdOrExternalId/clients/:clientId",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "v2",
            "apps",
            ":appId",
            "users",
            ":userIdOrExternalId",
            "clients",
            ":clientId"
          ],
          "variable": [
            {
              "key": "appId"
            },
            {
              "key": "userIdOrExternalId"
            },
            {
              "key": "clientId"
            }
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{}"
    },
    {
      "id": "473a1917-6c8f-47af-99f7-8a57d0e702f3",
      "name": "Cannot remove a client of type 'sdk'",
      "originalRequest": {
        "method": "DELETE",
        "header": [
          {
            "description": {
              "content": "Added as a part of security scheme: bearer",
              "type": "text/plain"
            },
            "key": "Authorization",
            "value": "Bearer <token>"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/v2/apps/:appId/users/:userIdOrExternalId/clients/:clientId",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "v2",
            "apps",
            ":appId",
            "users",
            ":userIdOrExternalId",
            "clients",
            ":clientId"
          ],
          "variable": [
            {
              "key": "appId"
            },
            {
              "key": "userIdOrExternalId"
            },
            {
              "key": "clientId"
            }
          ]
        }
      },
      "status": "Bad Request",
      "code": 400,
      "_postman_previewlanguage": "text",
      "header": [
        {
          "key": "Content-Type",
          "value": "text/plain"
        }
      ],
      "cookie": [
      ],
      "body": ""
    },
    {
      "id": "d3c4ce20-3c44-4db6-9bc2-7e11225e530d",
      "name": "Client not found",
      "originalRequest": {
        "method": "DELETE",
        "header": [
          {
            "description": {
              "content": "Added as a part of security scheme: bearer",
              "type": "text/plain"
            },
            "key": "Authorization",
            "value": "Bearer <token>"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/v2/apps/:appId/users/:userIdOrExternalId/clients/:clientId",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "v2",
            "apps",
            ":appId",
            "users",
            ":userIdOrExternalId",
            "clients",
            ":clientId"
          ],
          "variable": [
            {
              "key": "appId"
            },
            {
              "key": "userIdOrExternalId"
            },
            {
              "key": "clientId"
            }
          ]
        }
      },
      "status": "Not Found",
      "code": 404,
      "_postman_previewlanguage": "text",
      "header": [
        {
          "key": "Content-Type",
          "value": "text/plain"
        }
      ],
      "cookie": [
      ],
      "body": ""
    }
  ]
}