Chilkat Online Tools

unicodeC / Plivo REST API / Stop currently active recording

Back to Collection Items

#include <C_CkHttpW.h>
#include <C_CkJsonObjectW.h>
#include <C_CkStringBuilderW.h>
#include <C_CkHttpResponseW.h>

void ChilkatSample(void)
    {
    HCkHttpW http;
    BOOL success;
    HCkJsonObjectW json;
    HCkStringBuilderW sbRequestBody;
    HCkHttpResponseW resp;
    int respStatusCode;

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

    http = CkHttpW_Create();

    CkHttpW_putBasicAuth(http,TRUE);
    CkHttpW_putLogin(http,L"{{auth_id}}");
    CkHttpW_putPassword(http,L"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.

    // {
    //   "URL": "http://s3.amazonaws.com/recordings_2013/48dfaf60-3b2a-11e3.mp3"
    // }

    json = CkJsonObjectW_Create();
    CkJsonObjectW_UpdateString(json,L"URL",L"http://s3.amazonaws.com/recordings_2013/48dfaf60-3b2a-11e3.mp3");

    sbRequestBody = CkStringBuilderW_Create();
    CkJsonObjectW_EmitSb(json,sbRequestBody);

    resp = CkHttpW_PTextSb(http,L"DELETE",L"https://api.plivo.com/v1/Account/<auth_id>/Call/{call_uuid}/Record/",sbRequestBody,L"utf-8",L"application/json",FALSE,FALSE);
    if (CkHttpW_getLastMethodSuccess(http) == FALSE) {
        wprintf(L"%s\n",CkHttpW_lastErrorText(http));
        CkHttpW_Dispose(http);
        CkJsonObjectW_Dispose(json);
        CkStringBuilderW_Dispose(sbRequestBody);
        return;
    }

    respStatusCode = CkHttpResponseW_getStatusCode(resp);
    wprintf(L"Response Status Code = %d\n",respStatusCode);
    if (respStatusCode != 204) {
        wprintf(L"Response Header:\n");
        wprintf(L"%s\n",CkHttpResponseW_header(resp));
        wprintf(L"Response Body:\n");
        wprintf(L"%s\n",CkHttpResponseW_bodyStr(resp));
        wprintf(L"Failed.\n");
        CkHttpResponseW_Dispose(resp);
        CkHttpW_Dispose(http);
        CkJsonObjectW_Dispose(json);
        CkStringBuilderW_Dispose(sbRequestBody);
        return;
    }

    CkHttpResponseW_Dispose(resp);
    wprintf(L"Success.\n");


    CkHttpW_Dispose(http);
    CkJsonObjectW_Dispose(json);
    CkStringBuilderW_Dispose(sbRequestBody);

    }

Curl Command

curl -X DELETE
	-u '{{auth_id}}:password'
	-d '{
    "URL":"http://s3.amazonaws.com/recordings_2013/48dfaf60-3b2a-11e3.mp3"
}'
https://api.plivo.com/v1/Account/<auth_id>/Call/{call_uuid}/Record/

Postman Collection Item JSON

{
  "name": "Stop currently active recording",
  "request": {
    "method": "DELETE",
    "header": [
    ],
    "body": {
      "mode": "raw",
      "raw": "{\n    \"URL\":\"http://s3.amazonaws.com/recordings_2013/48dfaf60-3b2a-11e3.mp3\"\n}",
      "options": {
        "raw": {
          "language": "json"
        }
      }
    },
    "url": {
      "raw": "https://api.plivo.com/v1/Account/{{auth_id}}/Call/{call_uuid}/Record/",
      "protocol": "https",
      "host": [
        "api",
        "plivo",
        "com"
      ],
      "path": [
        "v1",
        "Account",
        "{{auth_id}}",
        "Call",
        "{call_uuid}",
        "Record",
        ""
      ]
    }
  },
  "response": [
    {
      "name": "Stop currently active recording",
      "originalRequest": {
        "method": "DELETE",
        "header": [
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n    \"URL\":\"http://s3.amazonaws.com/recordings_2013/48dfaf60-3b2a-11e3.mp3\"\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        },
        "url": {
          "raw": "https://api.plivo.com/v1/Account/{{auth_id}}/Call/{call_uuid}/Record/",
          "protocol": "https",
          "host": [
            "api",
            "plivo",
            "com"
          ],
          "path": [
            "v1",
            "Account",
            "{{auth_id}}",
            "Call",
            "{call_uuid}",
            "Record",
            ""
          ]
        }
      },
      "code": 204,
      "_postman_previewlanguage": "Text",
      "header": [
      ],
      "cookie": [
      ],
      "body": ""
    }
  ]
}