Validar blocos do template
curl --request POST \
--url http://localhost:4005/v1/templates/validate \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"blocks": [
{
"type": "variable",
"variable": "account.id"
}
]
}
'import requests
url = "http://localhost:4005/v1/templates/validate"
payload = { "blocks": [
{
"type": "variable",
"variable": "account.id"
}
] }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({blocks: [{type: 'variable', variable: 'account.id'}]})
};
fetch('http://localhost:4005/v1/templates/validate', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_PORT => "4005",
CURLOPT_URL => "http://localhost:4005/v1/templates/validate",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'blocks' => [
[
'type' => 'variable',
'variable' => 'account.id'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "http://localhost:4005/v1/templates/validate"
payload := strings.NewReader("{\n \"blocks\": [\n {\n \"type\": \"variable\",\n \"variable\": \"account.id\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("http://localhost:4005/v1/templates/validate")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"blocks\": [\n {\n \"type\": \"variable\",\n \"variable\": \"account.id\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("http://localhost:4005/v1/templates/validate")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"blocks\": [\n {\n \"type\": \"variable\",\n \"variable\": \"account.id\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"errors": [
{
"blockId": "customer-name",
"field": "variable",
"message": "variable must not be empty"
}
],
"valid": false
}{
"code": "ERR-0001",
"detail": "Property foo is required but is missing.",
"errors": [
{
"location": "body.templateId",
"message": "expected string to match 'uuid' format",
"value": "not-a-uuid"
}
],
"instance": "https://example.com/error-log/abc123",
"status": 400,
"title": "Bad Request",
"type": "https://example.com/errors/example"
}{
"code": "ERR-0001",
"detail": "Property foo is required but is missing.",
"errors": [
{
"location": "body.templateId",
"message": "expected string to match 'uuid' format",
"value": "not-a-uuid"
}
],
"instance": "https://example.com/error-log/abc123",
"status": 400,
"title": "Bad Request",
"type": "https://example.com/errors/example"
}{
"code": "ERR-0001",
"detail": "Property foo is required but is missing.",
"errors": [
{
"location": "body.templateId",
"message": "expected string to match 'uuid' format",
"value": "not-a-uuid"
}
],
"instance": "https://example.com/error-log/abc123",
"status": 400,
"title": "Bad Request",
"type": "https://example.com/errors/example"
}{
"code": "ERR-0001",
"detail": "Property foo is required but is missing.",
"errors": [
{
"location": "body.templateId",
"message": "expected string to match 'uuid' format",
"value": "not-a-uuid"
}
],
"instance": "https://example.com/error-log/abc123",
"status": 400,
"title": "Bad Request",
"type": "https://example.com/errors/example"
}Validar blocos do template
Valida blocos do template builder e retorna erros de validação semântica.
POST
/
v1
/
templates
/
validate
Validar blocos do template
curl --request POST \
--url http://localhost:4005/v1/templates/validate \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"blocks": [
{
"type": "variable",
"variable": "account.id"
}
]
}
'import requests
url = "http://localhost:4005/v1/templates/validate"
payload = { "blocks": [
{
"type": "variable",
"variable": "account.id"
}
] }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({blocks: [{type: 'variable', variable: 'account.id'}]})
};
fetch('http://localhost:4005/v1/templates/validate', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_PORT => "4005",
CURLOPT_URL => "http://localhost:4005/v1/templates/validate",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'blocks' => [
[
'type' => 'variable',
'variable' => 'account.id'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "http://localhost:4005/v1/templates/validate"
payload := strings.NewReader("{\n \"blocks\": [\n {\n \"type\": \"variable\",\n \"variable\": \"account.id\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("http://localhost:4005/v1/templates/validate")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"blocks\": [\n {\n \"type\": \"variable\",\n \"variable\": \"account.id\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("http://localhost:4005/v1/templates/validate")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"blocks\": [\n {\n \"type\": \"variable\",\n \"variable\": \"account.id\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"errors": [
{
"blockId": "customer-name",
"field": "variable",
"message": "variable must not be empty"
}
],
"valid": false
}{
"code": "ERR-0001",
"detail": "Property foo is required but is missing.",
"errors": [
{
"location": "body.templateId",
"message": "expected string to match 'uuid' format",
"value": "not-a-uuid"
}
],
"instance": "https://example.com/error-log/abc123",
"status": 400,
"title": "Bad Request",
"type": "https://example.com/errors/example"
}{
"code": "ERR-0001",
"detail": "Property foo is required but is missing.",
"errors": [
{
"location": "body.templateId",
"message": "expected string to match 'uuid' format",
"value": "not-a-uuid"
}
],
"instance": "https://example.com/error-log/abc123",
"status": 400,
"title": "Bad Request",
"type": "https://example.com/errors/example"
}{
"code": "ERR-0001",
"detail": "Property foo is required but is missing.",
"errors": [
{
"location": "body.templateId",
"message": "expected string to match 'uuid' format",
"value": "not-a-uuid"
}
],
"instance": "https://example.com/error-log/abc123",
"status": 400,
"title": "Bad Request",
"type": "https://example.com/errors/example"
}{
"code": "ERR-0001",
"detail": "Property foo is required but is missing.",
"errors": [
{
"location": "body.templateId",
"message": "expected string to match 'uuid' format",
"value": "not-a-uuid"
}
],
"instance": "https://example.com/error-log/abc123",
"status": 400,
"title": "Bad Request",
"type": "https://example.com/errors/example"
}Autorizações
Token bearer JWT emitido pelo provedor de identidade.
Corpo
application/json
Blocos do template que serão validados.
Blocos do template builder que serão validados.
Show child attributes
Show child attributes
Exemplo:
[
{
"type": "variable",
"variable": "account.id"
}
]
Resposta
OK
Esta página foi útil?

