Creación de procesos separados por flujos
En esta sección, encontrará ejemplos de solicitudes de creación de procesos en by Unico.
Solicitudes separadas por flujos
{
"callbackUri": "/path/to/url",
"flow": "id", //este es un ejemplo de flujo
"person": {
"duiType": "DUI_TYPE_MX_CURP",
"duiValue": "VNHK141228HQTFXW96",
"friendlyName": "Luke Skywalker",
"phone": "5215512345678",
"email": "teste@teste.com",
"notifications":
[
{
"notificationChannel": "NOTIFICATION_CHANNEL_WHATSAPP"
},
{
"notificationChannel": "NOTIFICATION_CHANNEL_SMS"
}
]
},
"purpose": "biometryonboarding",
"expiresIn": "3600s"
}
{
"callbackUri": "/path/to/url",
"flow": "idtoken", //este es un ejemplo de flujo
"bioTokenId": "339f9225-6f09-4303-9688-bf35944787e1",
"person": {
"duiType": "DUI_TYPE_MX_CURP",
"duiValue": "VNHK141228HQTFXW96"
"friendlyName": "Luke Skywalker",
"phone": "5215512345678",
"email": "teste@teste.com",
"notifications":
[
{
"notificationChannel": "NOTIFICATION_CHANNEL_WHATSAPP"
},
{
"notificationChannel": "NOTIFICATION_CHANNEL_SMS"
}
]
},
"purpose": "biometryonboarding",
"expiresIn": "3600s"
}
Outras formas de fazer uma requisição (request)
curl -X 'POST' \
'https://api.cadastro.uat.unico.app/client/v1/process/' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer {{TOKEN}}'
-d '{
"callbackUri": "/",
"flow": "id",
"person": {
"duiType": "DUI_TYPE_MX_CURP",
"duiValue": "VNHK141228HQTFXW96",
"friendlyName": "Luke Skywalker"
},
"purpose": "creditprocess"
}'
Para utilizar Postman, siga los pasos:
Seleccione el método POST.
Ingrese la URL
https://api.cadastro.uat.unico.app/client/v1/process/
.Seleccione la pestaña Authorization.
En la lista de Type, seleccione Bearer Token.
Ingrese el token obtenido en el campo Token con el prefijo
Bearer
.Seleccione la pestaña Body e ingrese los datos a continuación según su necesidad.
{
"callbackUri": "/paht/callback-url",
"flow": "id",
"person": {
"duiType": "DUI_TYPE_MX_CURP",
"duiValue": "VNHK141228HQTFXW96",
"friendlyName": "John Doe"
},
"purpose": "creditprocess"
}
const axios = require("axios");
const apiUrl = "https://api.cadastro.uat.unico.app/client/v1/process/";
const token = "<YOUR_TOKEN_HERE>";
const requestData = {
callbackUri: "/path/to/url",
flow: "id",
person: {
duiType: "DUI_TYPE_MX_CURP",
duiValue: "VNHK141228HQTFXW96",
friendlyName: "John Doe",
},
purpose: "creditprocess",
};
const headers = {
"Content-Type": "application/json",
Authorization: `Bearer ${token}`,
accept: "application/json",
};
axios
.post(apiUrl, requestData, { headers })
.then((response) => {
console.log("Resposta da API:", response.data);
})
.catch((error) => {
console.error("Erro:", error);
});
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.util.HashMap;
import java.util.Map;
public class Main {
public static void main(String[] args) {
String apiUrl = "https://api.cadastro.uat.unico.app/client/v1/process/";
String token = "<YOUR_TOKEN_HERE>";
// Crea el cuerpo de la solicitud en formato JSON.
String requestBody = "{\"callbackUri\":\"/\",\"flow\":\"id\",\"person\":{\"duiType\":\"DUI_TYPE_BR_CPF\",\"duiValue\":\"73689290074\"},\"purpose\":\"creditprocess\"}";
// Configura los encabezados de la solicitud
Map<String, String> headers = new HashMap<>();
headers.put("Content-Type", "application/json");
headers.put("Authorization", "Bearer " + token);
headers.put("accept", "application/json");
// Crea la instancia de HttpClient
HttpClient httpClient = HttpClient.newBuilder().build();
// Crea la solicitud HTTP POST
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(apiUrl))
.headers(headers.entrySet().stream()
.map(e -> e.getKey() + ":" + e.getValue())
.toArray(String[]::new))
.POST(HttpRequest.BodyPublishers.ofString(requestBody))
.build();
try {
// Envía la solicitud y obtiene la respuesta
HttpResponse<String> response = httpClient.send(request, HttpResponse.BodyHandlers.ofString());
// Muestra la respuesta de la API
System.out.println("Status da resposta: " + response.statusCode());
System.out.println("Corpo da resposta: " + response.body());
} catch (Exception e) {
e.printStackTrace();
}
}
}
using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
class Program
{
static async Task Main()
{
string apiUrl = "https://api.cadastro.uat.unico.app/client/v1/process/";
string token = "<YOUR_TOKEN_HERE>";
// Crea el cuerpo de la solicitud en formato JSON.
string requestBody = "{\"callbackUri\":\"/\",\"flow\":\"id\",\"person\":{\"duiType\":\"DUI_TYPE_BR_CPF\",\"duiValue\":\"73689290074\"},\"purpose\":\"creditprocess\"}";
// Configura los encabezados de la solicitud
HttpClient client = new HttpClient();
client.DefaultRequestHeaders.Add("Content-Type", "application/json");
client.DefaultRequestHeaders.Add("Authorization", "Bearer " + token);
client.DefaultRequestHeaders.Add("accept", "application/json");
try
{
// Envía la solicitud HTTP POST
HttpResponseMessage response = await client.PostAsync(apiUrl, new StringContent(requestBody, Encoding.UTF8, "application/json"));
// Verifica el estado de la respuesta
if (response.IsSuccessStatusCode)
{
string responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine("Status da resposta: " + response.StatusCode);
Console.WriteLine("Corpo da resposta: " + responseBody);
}
else
{
Console.WriteLine("Erro na solicitação. Status da resposta: " + response.StatusCode);
}
}
catch (Exception e)
{
Console.WriteLine("Erro: " + e.Message);
}
}
}
package main
import (
"bytes"
"fmt"
"net/http"
)
func main() {
apiURL := "https://api.cadastro.uat.unico.app/client/v1/process/"
token := "<YOUR_TOKEN_HERE>";
// Crea el cuerpo de la solicitud en formato JSON.
requestBody := []byte(`{
"callbackUri": "/path/to/url",
"flow": "id",
"person": {
"duiType": "DUI_TYPE_MX_CURP",
"duiValue": "VNHK141228HQTFXW96"
},
"purpose": "creditprocess"
}`)
// Crea un cliente HTTP
client := &http.Client{}
// Crea una solicitud HTTP POST
req, err := http.NewRequest("POST", apiURL, bytes.NewBuffer(requestBody))
if err != nil {
fmt.Println("Erro ao criar a solicitação HTTP:", err)
return
}
// Define los encabezados de la solicitud
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Authorization", "Bearer "+token)
req.Header.Set("accept", "application/json")
// Haz la solicitud HTTP
resp, err := client.Do(req)
if err != nil {
fmt.Println("Erro ao fazer a solicitação HTTP:", err)
return
}
defer resp.Body.Close()
// Verifica el estado de la respuesta
if resp.StatusCode == http.StatusOK {
// Lectura del cuerpo de la respuesta
var responseBody []byte
_, err := resp.Body.Read(responseBody)
if err != nil {
fmt.Println("Erro ao ler o corpo da resposta:", err)
return
}
fmt.Println("Status da resposta:", resp.Status)
fmt.Println("Corpo da resposta:", string(responseBody))
} else {
fmt.Println("Erro na solicitação. Status da resposta:", resp.Status)
}
}
¿Dudas?
Atualizado
Isto foi útil?