Chilkat Online Tools

C# / Sunshine Conversations API / Delete All Messages

Back to Collection Items

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

Chilkat.Http http = new Chilkat.Http();
bool success;

http.BasicAuth = true;
http.Login = "username";
http.Password = "password";

Chilkat.HttpResponse resp = http.QuickRequest("DELETE","https://domain.com/");
if (http.LastMethodSuccess == false) {
    Debug.WriteLine(http.LastErrorText);
    return;
}

Chilkat.StringBuilder sbResponseBody = new Chilkat.StringBuilder();
resp.GetBodySb(sbResponseBody);

Chilkat.JsonObject jResp = new Chilkat.JsonObject();
jResp.LoadSb(sbResponseBody);
jResp.EmitCompact = false;

Debug.WriteLine("Response Body:");
Debug.WriteLine(jResp.Emit());

int respStatusCode = resp.StatusCode;
Debug.WriteLine("Response Status Code = " + Convert.ToString(respStatusCode));
if (respStatusCode >= 400) {
    Debug.WriteLine("Response Header:");
    Debug.WriteLine(resp.Header);
    Debug.WriteLine("Failed.");

    return;
}

Curl Command

curl -X DELETE
	-u 'username:password'
https://domain.com/

Postman Collection Item JSON

{
  "name": "Delete All Messages",
  "_postman_id": "1607d306-d6b9-4db2-9681-ae0e7a978056",
  "request": {
    "method": "DELETE",
    "header": [
    ],
    "url": "{{url}}/v2/apps/{{appId}}/conversations/{{conversationId}}/messages",
    "description": "Delete all messages of a particular conversation."
  },
  "response": [
    {
      "id": "9484f369-d4b9-42ad-939b-5a63f02808e5",
      "name": "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/conversations/:conversationId/messages",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "v2",
            "apps",
            ":appId",
            "conversations",
            ":conversationId",
            "messages"
          ],
          "variable": [
            {
              "key": "appId"
            },
            {
              "key": "conversationId"
            }
          ]
        }
      },
      "status": "Not Found",
      "code": 404,
      "_postman_previewlanguage": "text",
      "header": [
        {
          "key": "Content-Type",
          "value": "text/plain"
        }
      ],
      "cookie": [
      ],
      "body": ""
    },
    {
      "id": "d977a6a4-f6fe-48c6-8123-8dc254542712",
      "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/conversations/:conversationId/messages",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "v2",
            "apps",
            ":appId",
            "conversations",
            ":conversationId",
            "messages"
          ],
          "variable": [
            {
              "key": "appId"
            },
            {
              "key": "conversationId"
            }
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{}"
    }
  ]
}