Android / Plivo REST API / Cold transfer a caller
Back to Collection Items
// Important: Don't forget to include the call to System.loadLibrary
// as shown at the bottom of this code sample.
package com.test;
import android.app.Activity;
import com.chilkatsoft.*;
import android.widget.TextView;
import android.os.Bundle;
public class SimpleActivity extends Activity {
private static final String TAG = "Chilkat";
// Called when the activity is first created.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
CkHttp http = new CkHttp();
boolean success;
http.put_BasicAuth(true);
http.put_Login("{{auth_id}}");
http.put_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.
// {
// "action": "cold_transfer",
// "to": "+14152225555",
// "role": "agent",
// "trigger_source": "+14152223333"
// }
CkJsonObject json = new CkJsonObject();
json.UpdateString("action","cold_transfer");
json.UpdateString("to","+14152225555");
json.UpdateString("role","agent");
json.UpdateString("trigger_source","+14152223333");
CkHttpResponse resp = http.PostJson3("https://phlorunner.plivo.com/v1/phlo/{phlo_id}/multi_party_call/{node_id}","application/json",json);
if (http.get_LastMethodSuccess() == false) {
Log.i(TAG, http.lastErrorText());
return;
}
Log.i(TAG, String.valueOf(resp.get_StatusCode()));
Log.i(TAG, resp.bodyStr());
}
static {
System.loadLibrary("chilkat");
// Note: If the incorrect library name is passed to System.loadLibrary,
// then you will see the following error message at application startup:
//"The application <your-application-name> has stopped unexpectedly. Please try again."
}
}
Curl Command
curl -X POST
-u '{{auth_id}}:password'
-d '{
"action": "cold_transfer",
"to": "+14152225555",
"role": "agent",
"trigger_source": "+14152223333"
}'
https://phlorunner.plivo.com/v1/phlo/{phlo_id}/multi_party_call/{node_id}
Postman Collection Item JSON
{
"name": "Cold transfer a caller",
"request": {
"method": "POST",
"header": [
],
"body": {
"mode": "raw",
"raw": "{\n \"action\": \"cold_transfer\",\n \"to\": \"+14152225555\",\n \"role\": \"agent\",\n \"trigger_source\": \"+14152223333\"\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "https://phlorunner.plivo.com/v1/phlo/{phlo_id}/multi_party_call/{node_id}",
"protocol": "https",
"host": [
"phlorunner",
"plivo",
"com"
],
"path": [
"v1",
"phlo",
"{phlo_id}",
"multi_party_call",
"{node_id}"
]
},
"description": "A User (U1) can transfer the call with a member (U2) on the Multi-Party Call to another user (U3). On Cold transfer, user U2 is connected directly to the user to whom the call is transferred to (U3) and the user initiating the cold transfer is disconnected from the Multi-Party Call.\n\nBelow is the list of arguments that can be passed in this API request, more information can be found [here](https://www.plivo.com/docs/phlo/api/phlo/multi-party-call/update-a-multi-party-call#cold-transfer-a-caller)\n\n| Arguments | Description | Required/Conditional/Optional |\n| :--- | :----: | ---: |\n| action | Set this parameter \"cold_transfer\".| Required |\n| to | Phone number or SIP endpoint address of the user to add to the Multi-party Call| Required |\n| role | Role of the user added to the Multi-Party Call. Allowed values are 'customer' and 'agent'. Defaults to agent. | Required |\n| trigger_source | Phone number or SIP endpoint address of the user (agent) initiating the trigger | Required |"
},
"response": [
{
"name": "Cold transfer a caller",
"originalRequest": {
"method": "POST",
"header": [
],
"body": {
"mode": "raw",
"raw": "{\n \"action\": \"cold_transfer\",\n \"to\": \"+14152225555\", // Phone number or SIP endpoint address of the user to which the call has to be transferred\n \"role\": \"agent\", // Role of the user added to the Multi-Party Call. Allowed values are 'customer' and 'agent'. Defaults to agent.\n \"trigger_source\": \"+14152223333\" // Phone number or SIP endpoint address of the user(agent) initiating the transfer\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "https://phlorunner.plivo.com/v1/phlo/{phlo_id}/multi_party_call/{node_id}",
"protocol": "https",
"host": [
"phlorunner",
"plivo",
"com"
],
"path": [
"v1",
"phlo",
"{phlo_id}",
"multi_party_call",
"{node_id}"
]
}
},
"code": 200,
"_postman_previewlanguage": "json",
"header": [
],
"cookie": [
],
"body": "{\n \"api_id\": \"8c77b816-d621-4028-afc8-1aeab1d497a8\",\n \"error\": \"\"\n}"
}
]
}