# Agregar registro a marcador

Agrega un registro a un marcador para lanzar la llamada en cuanto se tenga algún agente disponible, este registro serrá agregado a la cola, es decir se marcarán primero los registros que ya estaban en la cola independientemente, esta cola solo tomará encuenta los registros que no pertenecena una lista de marcación.

<p class="callout info">Usted puede verificar la [Colección de Postman](https://www.postman.com/dev-clever-ideas/ucontact/request/86fjj0d/dialertask?tab=overview "dialerTask") para ver un ejemplo y probar con su instancia.</p>

<p class="callout info">Todos los datos que esten encerrados por "{{ }}" son valores que serán reemplazado con los datos del propio cliente y/o la instancia correspondiente</p>

---

### HTTP Request

<table border="1" id="bkmrk-opcion-http-valor-re" style="border-collapse: collapse; width: 100%; height: 59.575px;"><tbody><tr style="height: 29.7875px;"><td class="align-center" style="width: 20.3956%; height: 29.7875px;">**Metodo**</td><td class="align-center" style="width: 79.6044%; height: 29.7875px;">**Recurso**</td></tr><tr style="height: 29.7875px;"><td style="width: 20.3956%; height: 29.7875px;">POST</td><td style="width: 79.6044%; height: 29.7875px;">/Integra/resources/Dialers/DialerTask</td></tr></tbody></table>

#### Request Header


<table border="1" id="bkmrk-opcion-valor-content" style="border-collapse: collapse; width: 100%; height: 89.3907px;"><tbody><tr style="height: 29.7969px;"><td class="align-center" style="width: 20.7664%; height: 29.7969px;">**Clave**</td><td class="align-center" style="width: 79.2336%; height: 29.7969px;">**Valor**</td></tr><tr style="height: 29.7969px;"><td style="width: 20.7664%; height: 29.7969px;">Content-Type</td><td style="width: 79.2336%; height: 29.7969px;">application/x-www-form-urlencoded</td></tr><tr style="height: 29.7969px;"><td style="width: 20.7664%; height: 29.7969px;">Authorization</td><td style="width: 79.2336%; height: 29.7969px;">Basic {{Token}}</td></tr></tbody></table>

#### Request Body

<table border="1" class="align-center" id="bkmrk-parametro-tipo-descr" style="border-collapse: collapse; width: 100%; height: 59.5938px;"><tbody><tr style="height: 29.7969px;"><td style="width: 20.5192%; height: 29.7969px;">**Parametro**</td><td style="width: 17.4289%; height: 29.7969px;">**Tipo**</td><td style="width: 13.8443%;">**Requerido**</td><td style="width: 48.2077%; height: 29.7969px;">**Descripción**</td></tr><tr style="height: 29.7969px;"><td data-colwidth="210" style="width: 20.5192%;">call

</td><td data-colwidth="549" style="width: 17.4289%;">JSON String (String)</td><td style="width: 13.8443%;">Si</td><td class="align-left" style="width: 48.2077%; height: 29.7969px;">Objeto Json convertido a texto en donde se agreguen los datos agregados en el siguient ejemplo</td></tr></tbody></table>

##### Ejemplo JSON

<p class="callout warning">Los datos agregados en el siguiente ejemplo son meramente demostrativos, tendrá que reemplazar los datos con los correspondiente a su instancia.</p>

```JSON
{
  "calldate" : null, 			// En caso de requerir se llame a una hora en especifico, ejemplo: '1900-01-01 00:00:00'
  "campaign" : "POWER<-", 		// Nombre de la campaña a agregar el registro
  "destination": "0123456789",	// Numero de teléfono al cual se realizará la marcación
  "alternatives": "",			// Numero alternativo al cual realizarle la llamada en caso de no contactar con el primer teléfono
  "agent" : "",					// Telefono/Extensión del agente en caso de querer que un agente en especifico tome la llamada
  "data": "idcustomer=7",		// Datos para mostrar en el formulario de la instancia o para utilizarlos para algo en especifico
  "source": "source",			// Pendiente
  "bulk": false,				// Pendiente
  "automatic": true				// Pendiente
}
```

##### Descripción de Objeto JSON

<p class="callout warning">En el JSON todos las Key deben estar agregadas, si el campo menciona que no es oblicatorio puede ser agregado con un valor vacio.</p>

<table border="1" id="bkmrk-parametro-tipo-reque" style="border-collapse: collapse; width: 100%; height: 297.969px;"><tbody><tr style="height: 29.7969px;"><td class="align-center" style="width: 20.5192%; height: 29.7969px;">**Parametro**</td><td class="align-center" style="width: 17.4289%; height: 29.7969px;">**Tipo**</td><td class="align-center" style="width: 13.8443%; height: 29.7969px;">**Requerido**</td><td class="align-center" style="width: 48.2077%; height: 29.7969px;">**Descripción**</td></tr><tr style="height: 29.7969px;"><td style="width: 20.5192%; height: 29.7969px;">calldate</td><td style="width: 17.4289%; height: 29.7969px;">Texto (String)</td><td class="align-center" style="width: 13.8443%; height: 29.7969px;">No</td><td style="width: 48.2077%; height: 29.7969px;">Define la hora en la cual se realizará la marcación, puede ser 'null' o fecha en formato '1900-01-01 00:00:00'.</td></tr><tr style="height: 29.7969px;"><td style="width: 20.5192%; height: 29.7969px;">campaign</td><td style="width: 17.4289%; height: 29.7969px;">Texto (String)</td><td class="align-center" style="width: 13.8443%; height: 29.7969px;">Si</td><td style="width: 48.2077%; height: 29.7969px;">Nombre de la campaña a la cual se agregará el registro</td></tr><tr style="height: 29.7969px;"><td style="width: 20.5192%; height: 29.7969px;">destination</td><td style="width: 17.4289%; height: 29.7969px;">Texto (String)</td><td class="align-center" style="width: 13.8443%; height: 29.7969px;">Si</td><td style="width: 48.2077%; height: 29.7969px;">Numero de teléfono al cual se marcará</td></tr><tr style="height: 29.7969px;"><td style="width: 20.5192%; height: 29.7969px;">alternatives</td><td style="width: 17.4289%; height: 29.7969px;">Texto (String)</td><td class="align-center" style="width: 13.8443%; height: 29.7969px;">No</td><td style="width: 48.2077%; height: 29.7969px;">Numero alternativos a contactar en caso no se logre contacto con el primer numero, puede ser vacio.</td></tr><tr style="height: 29.7969px;"><td style="width: 20.5192%; height: 29.7969px;">agent</td><td style="width: 17.4289%; height: 29.7969px;">Texto (String)</td><td class="align-center" style="width: 13.8443%; height: 29.7969px;">No</td><td style="width: 48.2077%; height: 29.7969px;">Numero del teléfono/extensión del agente en caso de requerir que un agente en especifico tome la llamada</td></tr><tr style="height: 29.7969px;"><td style="width: 20.5192%; height: 29.7969px;">data</td><td style="width: 17.4289%; height: 29.7969px;">Texto (String)</td><td class="align-center" style="width: 13.8443%; height: 29.7969px;">No</td><td style="width: 48.2077%; height: 29.7969px;">Datos a agregar para mostrarse en formularios, encuestas o para algún otro propocito dentro de la plataforma.</td></tr><tr style="height: 29.7969px;"><td style="width: 20.5192%; height: 29.7969px;">source</td><td style="width: 17.4289%; height: 29.7969px;">Texto (String)</td><td class="align-center" style="width: 13.8443%; height: 29.7969px;">Si</td><td style="width: 48.2077%; height: 29.7969px;">  
</td></tr><tr style="height: 29.7969px;"><td style="width: 20.5192%; height: 29.7969px;">bulk</td><td style="width: 17.4289%; height: 29.7969px;">Booleano (Boolean)</td><td class="align-center" style="width: 13.8443%; height: 29.7969px;">Si</td><td style="width: 48.2077%; height: 29.7969px;">  
</td></tr><tr style="height: 29.7969px;"><td style="width: 20.5192%; height: 29.7969px;">automatic</td><td style="width: 17.4289%; height: 29.7969px;">Booleano (Boolean)</td><td class="align-center" style="width: 13.8443%; height: 29.7969px;">Si</td><td style="width: 48.2077%; height: 29.7969px;">  
</td></tr></tbody></table>

---

### Ejemplos de codigo

<p class="callout info">Puede copiar los siguientes ejemplos de codigo y reemplazar las variables "{{variable}}" con los datos correctos.</p>

##### HTTP

```VBScript
POST /Integra/resources/Dialers/DialerTask HTTP/1.1
Host: {{Instance}}.ucontactcloud.com
Authorization: Basic {{Token}}
Content-Type: application/x-www-form-urlencoded
Content-Length: 310

call={{Objeto Json}}
```

##### cURL

```VBScript
curl --location --request POST 'https://testclever.ucontactcloud.com/Integra/resources/Dialers/DialerTask' \
--header 'Authorization: Basic VmNpc25lcm9zOjY3NDdjODIzLWY5ZmItNDY0My05NTc0LWNjMjJhOTlhZDRlMQ==' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'call={"calldate" : null,"campaign" : "POWER<-","destination": "1234567890","alternatives": "","agent" : "","data": "idcustomer=7","source": "source","bulk": false,"automatic": true }'
```

##### JavaScript

```JavaScript
var myHeaders = new Headers();
myHeaders.append("Authorization", "Basic {{Token}}");
myHeaders.append("Content-Type", "application/x-www-form-urlencoded");

var urlencoded = new URLSearchParams();
urlencoded.append("call", "{\"calldate\" : null,\"campaign\" : \"POWER<-\",\"destination\": \"0123456789\",\"alternatives\": \"\",\"agent\" : \"\",\"data\": \"idcustomer=7\",\"source\": \"source\",\"bulk\": false,\"automatic\": true }");

var requestOptions = {
  method: 'POST',
  headers: myHeaders,
  body: urlencoded,
  redirect: 'follow'
};

fetch("https://{{Instance}}.ucontactcloud.com/Integra/resources/Dialers/DialerTask", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));
```

##### JQuery

```JavaScript
var settings = {
  "url": "https://{{Instance}}.ucontactcloud.com/Integra/resources/Dialers/DialerTask",
  "method": "POST",
  "timeout": 0,
  "headers": {
    "Authorization": "Basic {{Token}}",
    "Content-Type": "application/x-www-form-urlencoded"
  },
  "data": {
    "call": "{\"calldate\" : null,\"campaign\" : \"POWER<-\",\"destination\": \"0123456789\",\"alternatives\": \"\",\"agent\" : \"\",\"data\": \"idcustomer=7\",\"source\": \"source\",\"bulk\": false,\"automatic\": true }"
  }
};

$.ajax(settings).done(function (response) {
  console.log(response);
});
```

##### C#

```C#
var client = new RestClient("https://{{Instance}}.ucontactcloud.com/Integra/resources/Dialers/DialerTask");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Basic {{Token}}");
request.AddHeader("Content-Type", "application/x-www-form-urlencoded");
request.AddParameter("call", "{\"calldate\" : null,\"campaign\" : \"POWER<-\",\"destination\": \"0123456789\",\"alternatives\": \"\",\"agent\" : \"\",\"data\": \"idcustomer=7\",\"source\": \"source\",\"bulk\": false,\"automatic\": true }");
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
```

##### Java

```Java
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded");
RequestBody body = RequestBody.create(mediaType, "call={\"calldate\" : null,\"campaign\" : \"POWER<-\",\"destination\": \"0123456789\",\"alternatives\": \"\",\"agent\" : \"\",\"data\": \"idcustomer=7\",\"source\": \"source\",\"bulk\": false,\"automatic\": true }");
Request request = new Request.Builder()
  .url("https://{{Instance}}.ucontactcloud.com/Integra/resources/Dialers/DialerTask")
  .method("POST", body)
  .addHeader("Authorization", "Basic {{Token}}")
  .addHeader("Content-Type", "application/x-www-form-urlencoded")
  .build();
Response response = client.newCall(request).execute();
```

##### Python

```Python
import http.client

conn = http.client.HTTPSConnection("{{Instance}}.ucontactcloud.com")
payload = 'call={{Objeto Json}}'
headers = {
  'Authorization': 'Basic {{Token}}',
  'Content-Type': 'application/x-www-form-urlencoded'
}
conn.request("POST", "/Integra/resources/Dialers/DialerTask", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
```

---

### HTTP Response

#### Respuesta Exitosa

```JSON
1
```

#### Respuesta de error

```JSON
0
```