Extensions
Extensions
Extensions let you create custom fields and widgets to customize Contentstack default UI and behavior.
You can now pass the branch header in the API request to fetch or manage modules located within specific branches of the stack. Additionally, you can also set the include_branch query parameter to true to include the _branch top-level key in the response. This key specifies the unique ID of the branch where the concerned Contentstack module resides.
uploadCustomField
The "Upload a custom field" request is used to upload a custom field to Contentstack.
| Name | Type | Description |
|---|---|---|
| upload | html | Select the HTML file of the custom field that you want to upload. |
| title | String | Enter the title of the custom field that you want to upload. |
| data_type | String | Enter the data type for the input field of the custom field. |
| tags | String | Enter the tags that you want to assign to the custom field. |
| multiple | Boolean | Enter ‘true’ if you want your custom field to store multiple values. |
| type | String | Enter the type as ‘field’ since this is a custom field extension. |
| Name | Type | Description |
|---|---|---|
| body (required) | JSONObject | The request body. |
import contentstack; Contentstack contentstack = new Contentstack.Builder().build(); Extensions extension = contntstack.stack().extensions(); extension.uploadCustomField(body);
update
The "Update Extensions call" will update the details of a custom field.
| Name | Type | Description |
|---|---|---|
| body (required) | JSONObject | The request body to update the Extension. |
import contentstack;
Contentstack contentstack = new Contentstack.Builder().build();
Extensions extension = contentstack.stack().extensions();
Call<ResponseBody> response = extension.update(body).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();
Extensions extension = contentstack.stack().extensions();
extension.removeParam("key");find
The "Get all custom fields" request is used to get the information of all custom fields created in a stack.
import contentstack;
Contentstack contentstack = new Contentstack.Builder().build();
Extensions extension = contentstack.stack().extensions();
Call<ResponseBody> response = extension.find().execute();
if (response.isSuccessful) {
System.out.println("Response" + response);
}addParam
Sets header for the request.
| 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();
Extensions extension = contentstack.stack().extensions();
extension.addParam("key", value);fetch
The "Fetch" request returns information about a specific extension.
import contentstack;
Contentstack contentstack = new Contentstack.Builder().build();
Extensions extension = contentstack.stack().extensions();
Call<ResponseBody> response = extension.fetch().execute();
if (response.isSuccessful) {
System.out.println("Response" + response);
}delete
The "Delete custom field" request deletes a specific custom field.
import contentstack;
Contentstack contentstack = new Contentstack.Builder().build();
Extensions extension = contentstack.stack().extensions();
Call<ResponseBody> response = extension.delete().execute();
if (response.isSuccessful) {
System.out.println("Response" + response);
}addHeader
Sets header for the request.
| 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();
Extensions extension = contentstack.stack().extensions();
extension.addHeader("key", value);