Wypełnij szablon danymi
POST
/api/v1/Templates
const url = 'https://twoja-instancja-template-engine-api.enterprise.sellrocket.pl/api/v1/Templates';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"template":"example","data":{"additionalProperty":"example"}}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://twoja-instancja-template-engine-api.enterprise.sellrocket.pl/api/v1/Templates \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "template": "example", "data": { "additionalProperty": "example" } }'Renderuje szablon tekstowy (składnia {{pole}}) na podstawie przekazanych danych i zwraca wynik; brakujące klucze dają puste miejsca. Przydatne do generowania treści wiadomości lub dokumentów.
If the data passed to the endpoint will not contain keys from template, segments where values should be located will be empty.
Example
Sending request like
{
"template": "zamowienie nr {{id}}, status: {{status.id}}, komentarz: {{NOT_EXISTING.comment}}",
"data": {
"id": 877,
"source": {
"connectionId": 12,
"connectionType": "MAG2",
"platformAccountId": "",
"platformOrderId": "1"
},
"status": {
"id": 1212121,
"from": "2023-12-14T11:56:18.511114Z"
}
}
}
Where there is no object NOT_EXISTING will return template zamowienie nr 877, status: 1212121, komentarz:
Autoryzacja
Dział zatytułowany „Autoryzacja”Treść żądania
Dział zatytułowany „Treść żądania”object
template
string
data
object
key
additional properties
Examplegenerated
{ "template": "example", "data": { "additionalProperty": "example" }}object
template
string
data
object
key
additional properties
Examplegenerated
{ "template": "example", "data": { "additionalProperty": "example" }}object
template
string
data
object
key
additional properties
Examplegenerated
{ "template": "example", "data": { "additionalProperty": "example" }}Odpowiedzi
Dział zatytułowany „Odpowiedzi”Success
Typ treściapplication/json
string
Examplegenerated
exampleBad Request
Typ treściapplication/json
object
statusCode
integer format: int32
Examplegenerated
{}Server Error

