Webhook
Webhook
A webhook is a mechanism that sends real-time information to any third-party app or service to keep your application in sync with your Contentstack account. Webhooks allow you to specify a URL to which you would like Contentstack to post data when an event happens.
getExecutionLog
This call will return a comprehensive detail of all the webhooks that were executed at a particular execution cycle.
| Name | Type | Description |
|---|---|---|
| executionUid (required) | String | The execution unique ID of the webhook. |
import contentstack;
Contentstack contentstack = new Contentstack.Builder().build();
Webhook webhook = contentstack.stack().webhook();
Call<ResponseBody> response = webhook.getExecutionLog("executionUid").execute();
if (response.isSuccessful) {
System.out.println("Response" + response);
}GetExecution
The "Get executions of a webhook" request allows you to fetch the execution details of a specific webhook, which includes the execution UID. These details are instrumental in retrieving webhook logs and retrying a failed webhook.
import contentstack;
Contentstack contentstack = new Contentstack.Builder().build();
Webhook webhook = contentstack.stack().webhook();
Call<ResponseBody> response = webhook.getExecutions().execute();
if (response.isSuccessful) {
System.out.println("Response" + response);
}importExisting
The "Import an Existing Webhook" request will allow you to update the details of an existing webhook.
import contentstack;
Contentstack contentstack = new Contentstack.Builder().build();
Webhook webhook = contentstack.stack().webhook();
Call<ResponseBody> response = webhook.importExisting().execute();
if (response.isSuccessful) {
System.out.println("Response" + response);
}export
import contentstack;
Contentstack contentstack = new Contentstack.Builder().build();
Webhook webhook = contentstack.stack().webhook();
Call<ResponseBody> response = webhook.export().execute();
if (response.isSuccessful) {
System.out.println("Response" + response);
}retry
This call makes a manual attempt to execute a webhook after the webhook has finished executing its automatic attempts.
When executing the API call, in the URI Parameter section, enter the execution UID that you receive when you execute the 'Get executions of webhooks' call.
| Name | Type | Description |
|---|---|---|
| executionUid (required) | String | The execution unique ID of the webhook. |
import contentstack;
Contentstack contentstack = new Contentstack.Builder().build();
Webhook webhook = contentstack.stack().webhook();
Call<ResponseBody> response = webhook.retry("executionUid").execute();
if (response.isSuccessful) {
System.out.println("Response" + response);
}removeParam
Set header for the request.
| Name | Type | Description |
|---|---|---|
| key (required) | String | Removes query parameters using the key of the request. |
import contentstack;
Contentstack contentstack = new Contentstack.Builder().build();
Webhook webhook = contentstack.stack().webhook();
webhook.removeParam("key");find
The "Get all Webhooks request" returns comprehensive information on all the available webhooks in the specified stack
When executing the API call, under the Header section, you need to enter the authtoken that you receive after logging into your account.
import contentstack;
Contentstack contentstack = new Contentstack.Builder().build();
Webhook webhook = contentstack.stack().webhook();
Call<ResponseBody> response = webhook.find().execute();
if (response.isSuccessful) {
System.out.println("Response" + response);
}fetch
The "Get webhook" request returns comprehensive information on a specific webhook.
import contentstack;
Contentstack contentstack = new Contentstack.Builder().build();
Webhook webhook = contentstack.stack().webhook();
Call<ResponseBody> response = webhook.fetch().execute();
if (response.isSuccessful) {
System.out.println("Response" + response);
}delete
The "Delete webhook" call deletes an existing webhook from a stack.
import contentstack;
Contentstack contentstack = new Contentstack.Builder().build();
Webhook webhook = contentstack.stack().webhook();
Call<ResponseBody> response = webhook.delete().execute();
if (response.isSuccessful) {
System.out.println("Response" + response);
}addParam
| Name | Type | Description |
|---|---|---|
| key (required) | String | Query parameter key for the request. |
| value (required) | Object | Query parameter value for the request. |
import contentstack;
Contentstack contentstack = new Contentstack.Builder().build();
Webhook webhook = contentstack.stack().webhook();
webhook.addParam("key", value);addHeader
| Name | Type | Description |
|---|---|---|
| key (required) | String | Header key for the request. |
| value (required) | Object | Header value for the request. |
import contentstack;
Contentstack contentstack = new Contentstack.Builder().build();
Webhook webhook = contentstack.stack().webhook();
webhook.addHeader("key", value);update
The "Update webhook" request allows you to update the details of an existing webhook in the stack.
| Name | Type | Description |
|---|---|---|
| requestBody (required) | JSONObject | The body should be of a JSONObject type. |
import contentstack;
Contentstack contentstack = new Contentstack.Builder().build();
Webhook webhook = contentstack.stack().webhook();
Call<ResponseBody> response = webhook.update(requestBody).execute();
if (response.isSuccessful) {
System.out.println("Response" + response);
}importWebhook
| Name | Type | Description |
|---|---|---|
| fileName (required) | String | the file name |
| jsonPath (required) | String | jsonPath like example "/Downloads/import.json" |
import contentstack;
Contentstack contentstack = new Contentstack.Builder().build();
Webhook webhook = contentstack.stack().webhook();
Call<ResponseBody> response = webhook.importWebhook("filename","jsonPath").execute();
if (response.isSuccessful) {
System.out.println("Response" + response);
}