Save over Webhook
This article describes how to send a webhook report. Instructions on how to work with tasks are described in the General information section.
Getting started
You will need the following tools and facilities:
Know how to use API key in FastReport Corporate Server.
This article will skip over additional information on authentication and authorization.
Curl tool.
Any other REST client will work, but the examples will be built for curl.
Active FastReport Corporate Server subscription.
Internet access.
Client application receiving requests.
Important! The items above describe recommended tools.
Important! This guide assumes that you have a client application that receives and processes incoming webhooks.
Create task
Let’s look how to create the task of sending a template over a webhook:
// Create a task
curl -X 'POST' \
'{your_host_name}/api/tasks/v1/Tasks' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"$t": "CreateWebhookTaskVM",
"name": "Webhook sending task",
"subscriptionId": "{workspace ID}",
"url": "http://example.com/",
"headers": {
"Authorization": "Bearer <token>",
"Content-Type": "multipart/form-data"
},
"inputFile": {
"entityId": "{template ID}",
"type": "Template"
}
}'
// Start a task by ID
curl -X 'POST' \
'{your_host_name}/api/tasks/v1/Tasks/{task ID}/run' \
-H 'accept: */*' \
-d ''
Important! Real object identifiers should be written to the EntityId and SubscriptionId fields. Otherwise, the task will be terminated with an error.
Important! The EntityId can be passed in the template, report, and export ID.
Execute task from the request body
curl -X 'POST' \
'{your_host_name}/api/tasks/v1/Tasks/run' \
-H 'accept: */*' \
-H 'Content-Type: application/json' \
-d '{
"$t": "RunWebhookTaskVM",
"name": "Webhook sending task",
"subscriptionId": "{workspace ID}",
"url": "http://example.com/",
"headers": {
"Authorization": "Bearer <token>",
"Content-Type": "multipart/form-data",
"Content-Length": "1278"
},
"inputFile": {
"entityId": "{template ID}",
"type": "Template"
}
}'
Important! In this case, the webhook sending will be done directly by this request and the task will not be saved in the database.
Example request that comes up on webhook’s endpoint:
{
"startedDateTime": "2024-06-07 08:37:09",
"request": {
"method": "POST",
"url": "https://example.com/6e259560-25e5-482b-a7b2-8c5267ba6ae3/",
"headers": [
{
"name": "connection",
"value": "close"
},
{
"name": "content-length",
"value": "1421"
},
{
"name": "content-type",
"value": "multipart/form-data; boundary=\"62ec6524-9360-4e91-834f-e9531e2d2c30\""
},
{
"name": "host",
"value": "example.com"
}
],
"bodySize": 0,
"postData": {
"mimeType": "application/json",
"text": ""
}
},
"response": {
"status": 200,
"httpVersion": "HTTP/1.1",
"headers": [
{
"name": "Content-Type",
"value": "text/html"
}
],
"content": {
"size": 145,
"text": "This URL has no default content configured.",
"mimeType": "text/html"
}
}
}
Important! There is no Authorization header in the examples because a cookie-based authentication model is used. For more information about authorization, please see Authentication and authorization.