REST API

Esta página de ayuda es para Studio. Esta información también está disponible para Desktop Studio.

Maneja de manera sincrónica las llamadas de la API RESTful. This action enables the system to handle higher loads. It returns both the body and headers for the API call. This makes it easier to test and debug scripts.

This action is one of the supported methods of connecting to web services in a Studio script.

If you have RESTful API requests currently completed in the Snippet action, it is strongly recommended that you replace them. You can use the REST API action, Integration Hub, or one of the other supported methods. Making API requests from SNIPPET may cause serious performance issues in the system.

Dependencias

There are limitations on the use of this action that are imposed at the business unitClosed Agrupación organizativa de alto nivel utilizada para administrar el soporte técnico, la facturación y la configuración global de su sistema NiCE CXone. level. This is done so that one should not impact the other. The limitations within the platform are:

  • Response Format: Only JSON response format is supported.
  • Retries on Failure: Action handler will automatically try two times if a failure message is received before returning the response.
  • Timeout: You specify the timeout value in the request. The value cannot be more than 90 seconds.
  • Max Response Size: The maximum response size is 32 KB. This is consistent with existing Snippet functionality. If you're reaching this limit, you must reduce the size of returned data.
  • Throttle Limit: The throttle limit is defined by two parameters:
    • Max Concurrent Requests: Up to 100 concurrent requests are allowed by default. This limit is the same for all NiCE CXone customers. This means that 100 concurrent requests result in much higher throughput than the making API calls from a Snippet action. If you need more than 100 concurrent requests, talk to your account representative about increasing the limit for your business unit. Special approvals are required.
    • In Queue Count: When requests exceed the limit, the extra requests enter a processing queue. Once requests drop below the limit, queued requests are processed.
  • Circuit Breaker: If your specified URL is down or unreachable, you can get too many failures on your request. When this happens, NiCE CXone will reduce request execution of ALL URLs from the REST API action for a period of time. This allows your specified URL to recover from the failure. Limits are identified below:
    • Minimum Throughput: 100 requests in 30 seconds. Once this threshold is reached, the failure rate is considered. If your business unit is not executing the minimum number of requests, it will continue to execute requests even if they're failing.
    • Failure Rate: When the minimum throughput threshold is reached, if at least 50% of the requests failed during 30 seconds, the back off time is triggered. The 30 seconds is a rolling window.
    • Back Off Time or Duration of Break: If the minimum throughput and failure rate are reached, no requests from the REST API action will execute for 30 seconds.

Other dependencies of this action are: 

  • JSON is the only supported response format. The action requires that all JSON be on a single line. When working with JSON in this action, you can:

    • Haga una sustitución de variables a partir de una cadena de caracteres que contenga JSON.
    • Convertir un objeto de datos dinámicos a JSON que es soportado al usar la función asjson(). Considere que asjson() trata todo como una cadena de caracteres, lo que significa que se requiere cierta manipulación al trabajar con valores booleanos o numéricos.
    • También puede pasar la variable de salida resultSet(out) de una acción previa REST API a esta propiedad.
  • Responses are returned as jtoken objects. You can work with them just as you would with dynamic data objects in your script.
  • Responses contain headers and the body of the response. They may also contain HTTP status codes. Not all responses will include status codes. If there is no error, if the REST API action fails to generate a valid response, or if the error returned cannot be parsed as a valid response, no status is included.
  • Responses contain headers and the body of the response. They also include HTTP status codes in two variables, __httpstatuscode and __httpstatusdescription. These variables populate from information returned from the server. However, they do not populate if there is an error, timeout, overflow, broken circuit, or another situation where the server does not return a response.
  • You can use more than one REST API action in a script, but they cannot both reference the same objects.

Tipos de script admitidos

A square with a line branching from it that goes to three other squares.

Generic

Email Chat Phone Voicemail Work Item SMS Digital

Propiedades de Entrada

Estas propiedades definen los datos que utiliza la acción al ejecutarse.

Las propiedad

Descripción

Add Caption

Ingrese una frase corta que identifique de forma única esta acción en el script. La leyenda aparece en el lienzo del script debajo del ícono de acción.

Verb

El verbo que quieres que utilice esta acción. Esta propiedad admite acciones REST básicas como GET, PUT, POST, DELETE y PATCH.

Parameters

Especifique los parámetros que se deben incluir o los datos que se deben publicar como objeto JSON de pares clave-valor. Se pueden aceptar muchos tipos de JSON, como Jobject , Jarray o Jtoken.

Headers

Le permite agregar encabezados personalizados para permitir la autenticación del cliente, como tokens de portador. Puede utilizar JSON en este campo.

Importante Si su punto final de URL personalizado requiere encabezados diferentes, debe especificarse en esta propiedad. Para mantener la paridad de funciones con la acción Snippet existente, NiCE CXone agrega los siguientes encabezados de manera predeterminada:

{"Accept":"application/json", "Content-Type" :"application/x-www-form-urlencoded"}

Command

Actualmente la única opción es MakeRestRequest. Esto funciona igual que la MakeRestRequest()función que se utiliza al hacer una llamada REST API en una acción Snippet.

Wait Time In MilliSeconds

Permite especificar y respetar un tiempo de espera de la llamada REST. Debe ser menos de 90 segundos (90000 milisegundos). Si no se especifica ningún tiempo límite, el valor predeterminado es de 10 segundos (10000 milisegundos).

Service Address

El URL de la API REST que desee que llame la acción. Puede utilizar la sustitución de variables con esta propiedad. Use la propiedad Parameters para especificar los parámetros de consulta que desea incluir.

Timeout

La ruta adoptada si no hay respuesta durante la cantidad de segundos o milisegundos que se especifican en la propiedad Timeout.

Output Properties

Estas propiedades contienen variables que incluyen datos que se evuelven al ejecutar la acción. Están disponibles como referencia y para usarse cuando se completa la acción.

Las propiedad

Descripción

Result Set

Una variable que mantiene información devuelta por la API especificada en la Dirección del Servicio. De ser necesario, usted puede transferir el contenido de esta variable tal cual es al encabezado y los parámetros. La respuesta se devuelve como un objeto Jtoken, pero puede declararlo como un objeto dinámico y trabajar con él como lo haría con otros objetos dinámicos en su script.

Error Arg List

Un objeto de datos dinámico que almacena información sobre cualquier error que se presente. Cuando se presenta un error, el objeto almacena el código de estatus, la descripción del estatus y el mensaje del HTTP. Cuando no hay error, el objeto está vacío.

Los códigos de estatus y las descripciones de HTTP se devuelven únicamente en el error y se pueden analizar adecuadamente como respuesta válida. Esto significa que no todos los errores incluirán un código de respuesta HTTP.

Result Branch Conditions

Las condiciones de las ramas de resultados le permiten crear ramas en su script para manejar diferentes resultados cuando se ejecute una acción.

Condición

Descripción

Throttle

Ruta tomada cuando se ejecutan demasiadas solicitudes en un período corto de tiempo. Consulte las limitaciones a continuación para obtener más detalles.

InvalidInput

Ruta tomada si se encuentra una entrada no válida o se produce un error de tiempo de espera. Cada parámetro se valida cuando se guarda el script.

Failure

Path taken when any error or exception happens within the NiCE CXone application executing the request.

Error

Ruta tomada cuando el punto final del cliente remoto devuelve un código de error http.

Default

Camino tomado cuando la respuesta no se recibe dentro de los 90 segundos.

Success

Ruta que se toma si la acción finaliza sin errores y cualquier llamada API o devolución de datos se realiza correctamente (códigos de respuesta 2xx).