Releases
Releases
A Release is a set of entries and assets, each with a publish or unpublish action, that you deploy to environments together. Use this class to
- list the Releases of a stack, or read one Release
- create, update, clone, and delete a Release
- deploy a Release to environments, now or at a scheduled time
- reach the items of a Release through the ReleaseItem class
stack.releases() and stack.releases("<RELEASE_UID>") return a Release. Release has no public constructor.
| Name | Type | Description |
|---|---|---|
| releaseUid | String | UID of the Release. Pass it to stack.releases() for methods that act on one Release. |
addHeader
addHeader adds one request header to this release.
| Name | Type | Description |
|---|---|---|
| key (required) | String | Name of the header. |
| value (required) | String | Value of the header. |
Returns: Release. The same release, for chaining.
Validation
- There is no client-side validation. A null key or value does not throw here.
- execute() throws IllegalArgumentException for a null key or value, because Retrofit rejects null entries in a header map.
- An invalid value surfaces as an API error in the response when you call execute() on the request this method feeds.
Additional Resource Refer to Content Management API Errors for the full error code list.
Behavior
- addHeader stores the header in the header map of this object and sends nothing.
- A later call with the same name replaces the value.
- The header goes on every request of this release object, and stays there for every later request.
- item copies the headers of the release, so a header you add before you call item() also goes on every release item request.
Example
Basic usage: send the release_version header
import com.contentstack.cms.Contentstack;
import okhttp3.ResponseBody;
import retrofit2.Response;
import java.io.IOException;
public class ListReleasesV2 {
public static void main(String[] args) throws IOException {
Contentstack client = new Contentstack.Builder().build();
Response<ResponseBody> response = client.stack("<API_KEY>", "<MANAGEMENT_TOKEN>")
.releases()
.addHeader("release_version", "2.0")
.find()
.execute();
if (!response.isSuccessful()) {
// The API rejected the request. The body holds error_message, error_code and errors.
System.out.println("Request failed: " + response.code() + " " + response.errorBody().string());
return;
}
System.out.println(response.body().string());
}
}addHeaders
addHeaders adds every entry of a map to the request headers of this release.
| Name | Type | Description |
|---|---|---|
| headers (required) | HashMap<String, String> | Header names mapped to their values. |
Returns: Release. The same release, for chaining.
Validation
- Throws NullPointerException if headers is null, because addHeaders copies every entry of the map.
- execute() throws IllegalArgumentException for a null key or value in the map, because Retrofit rejects null entries in a header map.
- An invalid value surfaces as an API error in the response when you call execute() on the request this method feeds.
Additional Resource Refer to Content Management API Errors for the full error code list.
Behavior
- addHeaders copies the entries into the header map of this object and sends nothing.
- An entry replaces a header with the same name.
- The headers go on every request of this release object, and stay there for every later request.
- item copies the headers of the release, so a header you add before you call item() also goes on every release item request.
Example
Basic usage: send the release version and branch headers
import com.contentstack.cms.Contentstack;
import okhttp3.ResponseBody;
import retrofit2.Response;
import java.io.IOException;
import java.util.HashMap;
public class ListBranchReleases {
public static void main(String[] args) throws IOException {
Contentstack client = new Contentstack.Builder().build();
HashMap<String, String> headers = new HashMap<>();
headers.put("release_version", "2.0");
headers.put("branch", "<BRANCH>");
Response<ResponseBody> response = client.stack("<API_KEY>", "<MANAGEMENT_TOKEN>")
.releases()
.addHeaders(headers)
.find()
.execute();
if (!response.isSuccessful()) {
// The API rejected the request. The body holds error_message, error_code and errors.
System.out.println("Request failed: " + response.code() + " " + response.errorBody().string());
return;
}
System.out.println(response.body().string());
}
}addParam
addParam adds one query parameter to this release.
| Name | Type | Description |
|---|---|---|
| key (required) | String | Name of the query parameter. |
| value (required) | Object | Value of the query parameter, sent as its string form. |
Returns: Release. The same release, for chaining.
Validation
- There is no client-side validation. A null key or value does not throw here.
- execute() throws IllegalArgumentException for a null key or value, because Retrofit rejects null entries in a query map.
- An invalid value surfaces as an API error in the response when you call execute() on the request this method feeds.
Additional Resource Refer to Content Management API Errors for the full error code list.
Behavior
- addParam stores the pair in the query parameter map of this object and sends nothing.
- A later call with the same key replaces the value.
- The parameter goes on find and clone. fetch, create, update, delete, and deploy send no query parameters.
- The parameter stays on the object for every later request. Remove it with removeParam.
- The ReleaseItem object from item does not receive these parameters.
Example
Basic usage: add the total count to the release list
import com.contentstack.cms.Contentstack;
import okhttp3.ResponseBody;
import retrofit2.Response;
import java.io.IOException;
public class CountReleases {
public static void main(String[] args) throws IOException {
Contentstack client = new Contentstack.Builder().build();
Response<ResponseBody> response = client.stack("<API_KEY>", "<MANAGEMENT_TOKEN>")
.releases()
.addParam("include_count", true)
.find()
.execute();
if (!response.isSuccessful()) {
// The API rejected the request. The body holds error_message, error_code and errors.
System.out.println("Request failed: " + response.code() + " " + response.errorBody().string());
return;
}
System.out.println(response.body().string());
}
}addParams
addParams adds every entry of a map to the query parameters of this release.
| Name | Type | Description |
|---|---|---|
| params (required) | HashMap<String, Object> | Query parameter names mapped to their values. |
Returns: Release. The same release, for chaining.
Validation
- Throws NullPointerException if params is null, because addParams copies every entry of the map.
- execute() throws IllegalArgumentException for a null key or value in the map, because Retrofit rejects null entries in a query map.
- An invalid value surfaces as an API error in the response when you call execute() on the request this method feeds.
Additional Resource Refer to Content Management API Errors for the full error code list.
Behavior
- addParams copies the entries into the query parameter map of this object and sends nothing.
- An entry replaces a parameter with the same name.
- The parameters go on find and clone. fetch, create, update, delete, and deploy send no query parameters.
- The parameters stay on the object for every later request. Remove one with removeParam.
- The ReleaseItem object from item does not receive these parameters.
Example
Basic usage: read five releases with their item counts
import com.contentstack.cms.Contentstack;
import okhttp3.ResponseBody;
import retrofit2.Response;
import java.io.IOException;
import java.util.HashMap;
public class PageReleases {
public static void main(String[] args) throws IOException {
Contentstack client = new Contentstack.Builder().build();
HashMap<String, Object> params = new HashMap<>();
params.put("limit", 5);
params.put("skip", 0);
params.put("include_items_count", true);
Response<ResponseBody> response = client.stack("<API_KEY>", "<MANAGEMENT_TOKEN>")
.releases()
.addParams(params)
.find()
.execute();
if (!response.isSuccessful()) {
// The API rejected the request. The body holds error_message, error_code and errors.
System.out.println("Request failed: " + response.code() + " " + response.errorBody().string());
return;
}
System.out.println(response.body().string());
}
}clone
clone builds the request that copies the Release whose UID you passed to stack.releases() into a new Release with the name you pass.
| Name | Type | Description |
|---|---|---|
| requestBody (required) | JSONObject | Request body with the new details under a release key. |
| requestBody.release.name (required) | String | Sets the name of the cloned Release. |
| requestBody.release.description | String | Sets the description of the cloned Release. |
Returns: Call<ResponseBody>. The request for the cloned Release, sent when you call execute().
Validation
- Throws IllegalAccessError if the Release has no UID or an empty UID, because the request path needs the Release UID.
- execute() throws IllegalArgumentException if requestBody is null, because Retrofit cannot build a request without a body.
- An API rejection does not throw. response.isSuccessful() is false and the error details are in response.errorBody().
Additional Resource Refer to Content Management API Errors for the full error code list.
Behavior
- One execute() sends one Clone a Release request (POST /releases/{release_uid}/clone) with requestBody as the JSON body and the query parameters of this object.
- The API reference lists include_branch as a query parameter for this request. Add it with addParam.
- The source Release stays unchanged.
Example
Basic usage: clone a Release under a new name
import com.contentstack.cms.Contentstack;
import okhttp3.ResponseBody;
import org.json.simple.JSONObject;
import retrofit2.Response;
import java.io.IOException;
public class CloneRelease {
public static void main(String[] args) throws IOException {
Contentstack client = new Contentstack.Builder().build();
JSONObject release = new JSONObject();
release.put("name", "docs-test-release-copy");
release.put("description", "Copy of the spring campaign Release");
JSONObject requestBody = new JSONObject();
requestBody.put("release", release);
Response<ResponseBody> response = client.stack("<API_KEY>", "<MANAGEMENT_TOKEN>")
.releases("<RELEASE_UID>")
.addParam("include_branch", true)
.clone(requestBody)
.execute();
if (!response.isSuccessful()) {
// The API rejected the request. The body holds error_message, error_code and errors.
System.out.println("Request failed: " + response.code() + " " + response.errorBody().string());
return;
}
System.out.println(response.body().string());
}
}create
create builds the request that creates a Release in the stack with the name you pass.
| Name | Type | Description |
|---|---|---|
| requestBody (required) | JSONObject | Request body with the Release details under a release key. |
| requestBody.release.name (required) | String | Sets the name of the Release. |
| requestBody.release.description | String | Sets the description of the Release. |
Returns: Call<ResponseBody>. The request for the new Release, sent when you call execute().
Validation
- There is no client-side validation of requestBody. The SDK sends it unchanged.
- execute() throws IllegalArgumentException if requestBody is null, because Retrofit cannot build a request without a body.
- An API rejection does not throw. response.isSuccessful() is false and the error details are in response.errorBody().
Additional Resource Refer to Content Management API Errors for the full error code list.
Behavior
- One execute() sends one Create a Release request (POST /releases) with requestBody as the JSON body. create sends no query parameters.
- create ignores the UID of this object, so it works on stack.releases() and on stack.releases("<RELEASE_UID>").
- The new Release holds no items. Add them with the item method.
Example
Basic usage: create a Release
import com.contentstack.cms.Contentstack;
import okhttp3.ResponseBody;
import org.json.simple.JSONObject;
import retrofit2.Response;
import java.io.IOException;
public class CreateRelease {
public static void main(String[] args) throws IOException {
Contentstack client = new Contentstack.Builder().build();
JSONObject release = new JSONObject();
release.put("name", "docs-test-release");
JSONObject requestBody = new JSONObject();
requestBody.put("release", release);
Response<ResponseBody> response = client.stack("<API_KEY>", "<MANAGEMENT_TOKEN>")
.releases()
.create(requestBody)
.execute();
if (!response.isSuccessful()) {
// The API rejected the request. The body holds error_message, error_code and errors.
System.out.println("Request failed: " + response.code() + " " + response.errorBody().string());
return;
}
System.out.println(response.body().string());
}
}All parameters: create a Release with a description
import com.contentstack.cms.Contentstack;
import okhttp3.ResponseBody;
import org.json.simple.JSONObject;
import retrofit2.Response;
import java.io.IOException;
public class CreateReleaseWithDescription {
public static void main(String[] args) throws IOException {
Contentstack client = new Contentstack.Builder().build();
JSONObject release = new JSONObject();
release.put("name", "docs-test-release");
release.put("description", "Spring campaign pages");
JSONObject requestBody = new JSONObject();
requestBody.put("release", release);
Response<ResponseBody> response = client.stack("<API_KEY>", "<MANAGEMENT_TOKEN>")
.releases()
.addHeader("release_version", "2.0")
.create(requestBody)
.execute();
if (!response.isSuccessful()) { System.out.println(response.errorBody().string()); return; }
System.out.println(response.body().string());
}
}delete
delete builds the request that deletes the Release whose UID you passed to stack.releases().
Returns: Call<ResponseBody>. The request that deletes the Release, sent when you call execute().
Validation
- Throws IllegalAccessError if the Release has no UID or an empty UID, because the request path needs the Release UID.
- An API rejection does not throw. response.isSuccessful() is false and the error details are in response.errorBody().
Additional Resource Refer to Content Management API Errors for the full error code list.
Behavior
- One execute() sends one Delete a Release request (DELETE /releases/{release_uid}) with the headers of this object. delete sends no query parameters and no body.
- The SDK leaves the Content-Type header off this request, because the request has no body.
Example
Basic usage: delete a Release
import com.contentstack.cms.Contentstack;
import okhttp3.ResponseBody;
import retrofit2.Response;
import java.io.IOException;
public class DeleteRelease {
public static void main(String[] args) throws IOException {
Contentstack client = new Contentstack.Builder().build();
Response<ResponseBody> response = client.stack("<API_KEY>", "<MANAGEMENT_TOKEN>")
.releases("<RELEASE_UID>")
.delete()
.execute();
if (!response.isSuccessful()) {
// The API rejected the request. The body holds error_message, error_code and errors.
System.out.println("Request failed: " + response.code() + " " + response.errorBody().string());
return;
}
System.out.println(response.body().string());
}
}deploy
deploy builds the request that deploys the Release whose UID you passed to stack.releases() to the environments you name, now or at a scheduled time.
| Name | Type | Description |
|---|---|---|
| requestBody (required) | JSONObject | Request body with the deployment details under a release key. |
| requestBody.release.environments (required) | List<String> | Environments to deploy the Release to. |
| requestBody.release.locales | List<String> | Locales to deploy the Release in. |
| requestBody.release.action (required) | String | Deployment action, publish or unpublish. |
| requestBody.release.scheduled_at | String | Time to deploy a scheduled Release. |
Returns: Call<ResponseBody>. The request that deploys the Release, sent when you call execute().
Validation
- Throws IllegalAccessError if the Release has no UID or an empty UID, because the request path needs the Release UID.
- execute() throws IllegalArgumentException if requestBody is null, because Retrofit cannot build a request without a body.
- An API rejection does not throw. response.isSuccessful() is false and the error details are in response.errorBody().
Additional Resource Refer to Content Management API Errors for the full error code list.
Behavior
- One execute() sends one Deploy a Release request (POST /releases/{release_uid}/deploy) with requestBody as the JSON body. deploy sends no query parameters.
- To cancel a scheduled deployment, use the cancelScheduledAction method of PublishQueue.
Example
Basic usage: deploy a Release now
import com.contentstack.cms.Contentstack;
import okhttp3.ResponseBody;
import org.json.simple.JSONObject;
import retrofit2.Response;
import java.io.IOException;
import java.util.Collections;
public class DeployRelease {
public static void main(String[] args) throws IOException {
Contentstack client = new Contentstack.Builder().build();
JSONObject release = new JSONObject();
release.put("environments", Collections.singletonList("<ENVIRONMENT>"));
release.put("action", "publish");
JSONObject requestBody = new JSONObject();
requestBody.put("release", release);
Response<ResponseBody> response = client.stack("<API_KEY>", "<MANAGEMENT_TOKEN>")
.releases("<RELEASE_UID>")
.deploy(requestBody)
.execute();
if (!response.isSuccessful()) {
// The API rejected the request. The body holds error_message, error_code and errors.
System.out.println("Request failed: " + response.code() + " " + response.errorBody().string());
return;
}
System.out.println(response.body().string());
}
}All parameters: schedule a deployment in one locale
import com.contentstack.cms.Contentstack;
import okhttp3.ResponseBody;
import org.json.simple.JSONObject;
import retrofit2.Response;
import java.io.IOException;
import java.util.Collections;
public class ScheduleRelease {
public static void main(String[] args) throws IOException {
Contentstack client = new Contentstack.Builder().build();
JSONObject release = new JSONObject();
release.put("environments", Collections.singletonList("<ENVIRONMENT>"));
release.put("locales", Collections.singletonList("<LOCALE>"));
release.put("action", "publish");
release.put("scheduled_at", "2026-12-01T09:00:00.000Z");
JSONObject requestBody = new JSONObject();
requestBody.put("release", release);
Response<ResponseBody> response = client.stack("<API_KEY>", "<MANAGEMENT_TOKEN>")
.releases("<RELEASE_UID>")
.deploy(requestBody)
.execute();
if (!response.isSuccessful()) { System.out.println(response.errorBody().string()); return; }
System.out.println(response.body().string());
}
}fetch
fetch builds the request that reads one Release by the UID you passed to stack.releases().
Returns: Call<ResponseBody>. The request for the Release, sent when you call execute().
Validation
- Throws IllegalAccessError if the Release has no UID or an empty UID, because the request path needs the Release UID.
- An API rejection does not throw. response.isSuccessful() is false and the error details are in response.errorBody().
Additional Resource Refer to Content Management API Errors for the full error code list.
Behavior
- One execute() sends one Get a single Release request (GET /releases/{release_uid}) with the headers of this object.
- fetch sends no query parameters, so include_branch from addParam does not reach this request.
Example
Basic usage: read one Release
import com.contentstack.cms.Contentstack;
import okhttp3.ResponseBody;
import retrofit2.Response;
import java.io.IOException;
public class FetchRelease {
public static void main(String[] args) throws IOException {
Contentstack client = new Contentstack.Builder().build();
Response<ResponseBody> response = client.stack("<API_KEY>", "<MANAGEMENT_TOKEN>")
.releases("<RELEASE_UID>")
.fetch()
.execute();
if (!response.isSuccessful()) {
// The API rejected the request. The body holds error_message, error_code and errors.
System.out.println("Request failed: " + response.code() + " " + response.errorBody().string());
return;
}
System.out.println(response.body().string());
}
}Error handling: a Release object without a UID
import com.contentstack.cms.Contentstack;
import com.contentstack.cms.stack.Release;
public class FetchReleaseWithoutUid {
public static void main(String[] args) {
Contentstack client = new Contentstack.Builder().build();
Release release = client.stack("<API_KEY>", "<MANAGEMENT_TOKEN>").releases();
try {
release.fetch();
} catch (IllegalAccessError e) {
// Fires because releases() holds no UID. IllegalAccessError is an Error, not an Exception.
System.out.println("Pass a Release UID to stack.releases(): " + e.getMessage());
}
}
}find
find builds the request that lists the Releases of the stack, with the query parameters on this object.
Returns: Call<ResponseBody>. The request for all Releases in the stack, sent when you call execute().
Validation
- There is no client-side validation. find works on stack.releases() and on stack.releases("<RELEASE_UID>"), and ignores the UID.
- An API rejection does not throw. response.isSuccessful() is false and the error details are in response.errorBody().
Additional Resource Refer to Content Management API Errors for the full error code list.
Behavior
- One execute() sends one Get all Releases request (GET /releases) with the headers and query parameters of this object.
- The API reference lists the following six query parameters, which you add with addParam:
- include_count: true adds the total number of Releases to the response.
- count: true returns only the total number of Releases, without their details.
- include_items_count: true adds the number of items in each Release.
- limit: the maximum number of Releases to return.
- skip: the number of Releases to skip.
- include_branch: true adds the _branch key to each Release.
- The SDK does not page through the results. Without limit and skip, the API applies its own page size.
Example
Basic usage: list the Releases of a stack
import com.contentstack.cms.Contentstack;
import okhttp3.ResponseBody;
import retrofit2.Response;
import java.io.IOException;
public class ListReleases {
public static void main(String[] args) throws IOException {
Contentstack client = new Contentstack.Builder().build();
Response<ResponseBody> response = client.stack("<API_KEY>", "<MANAGEMENT_TOKEN>")
.releases()
.find()
.execute();
if (!response.isSuccessful()) {
// The API rejected the request. The body holds error_message, error_code and errors.
System.out.println("Request failed: " + response.code() + " " + response.errorBody().string());
return;
}
System.out.println(response.body().string());
}
}Pagination: read five Releases with counts
import com.contentstack.cms.Contentstack;
import okhttp3.ResponseBody;
import retrofit2.Response;
import java.io.IOException;
public class ListReleasesPage {
public static void main(String[] args) throws IOException {
Contentstack client = new Contentstack.Builder().build();
Response<ResponseBody> response = client.stack("<API_KEY>", "<MANAGEMENT_TOKEN>")
.releases()
.addParam("limit", 5)
.addParam("skip", 0)
.addParam("include_count", true)
.addParam("include_items_count", true)
.find()
.execute();
if (!response.isSuccessful()) { System.out.println(response.errorBody().string()); return; }
System.out.println(response.body().string());
}
}item
item returns a ReleaseItem object for reading, adding, updating, moving, and removing the items of this Release.
Returns: ReleaseItem. A new release item object for this Release.
Validation
- Throws IllegalAccessError if the Release has no UID or an empty UID, because every release item request needs the Release UID.
- There is no other client-side validation. Errors come from execute() on the requests of the ReleaseItem object.
Additional Resource Refer to Content Management API Errors for the full error code list.
Behavior
- item sends no request. It returns a new object on each call.
- The new object copies the headers that this Release holds at the time of the call, including release_version and branch if you added them. It does not copy the query parameters.
- Headers that you add to the Release after the call do not reach the ReleaseItem.
Example
Basic usage: list the items of a Release
import com.contentstack.cms.Contentstack;
import com.contentstack.cms.stack.ReleaseItem;
import okhttp3.ResponseBody;
import retrofit2.Response;
import java.io.IOException;
public class ListReleaseItems {
public static void main(String[] args) throws IOException {
Contentstack client = new Contentstack.Builder().build();
// Add release_version before item(), so the ReleaseItem copies it
ReleaseItem items = client.stack("<API_KEY>", "<MANAGEMENT_TOKEN>")
.releases("<RELEASE_UID>")
.addHeader("release_version", "2.0")
.item();
Response<ResponseBody> response = items.find().execute();
if (!response.isSuccessful()) {
// The API rejected the request. The body holds error_message, error_code and errors.
System.out.println("Request failed: " + response.code() + " " + response.errorBody().string());
return;
}
System.out.println(response.body().string());
}
}removeParam
removeParam removes one query parameter from this release.
| Name | Type | Description |
|---|---|---|
| key (required) | String | Name of the query parameter to remove. |
Returns: void. This method returns nothing.
Validation
- There is no client-side validation. A key that is not in the map, or null, changes nothing and does not throw.
- An invalid value surfaces as an API error in the response when you call execute() on the request this method feeds.
Additional Resource Refer to Content Management API Errors for the full error code list.
Behavior
- removeParam deletes the key from the query parameter map of this object and sends nothing.
- removeParam returns nothing, so it cannot sit in a chain. Call it as a separate statement.
- removeParam leaves the headers of the object unchanged.
Example
Basic usage: remove a parameter before the next request
import com.contentstack.cms.Contentstack;
import com.contentstack.cms.stack.Release;
import okhttp3.ResponseBody;
import retrofit2.Response;
import java.io.IOException;
public class RemoveReleaseParam {
public static void main(String[] args) throws IOException {
Contentstack client = new Contentstack.Builder().build();
Release releases = client.stack("<API_KEY>", "<MANAGEMENT_TOKEN>").releases();
releases.addParam("include_count", true);
releases.addParam("limit", 5);
// The next request sends limit only
releases.removeParam("include_count");
Response<ResponseBody> response = releases.find().execute();
if (!response.isSuccessful()) {
// The API rejected the request. The body holds error_message, error_code and errors.
System.out.println("Request failed: " + response.code() + " " + response.errorBody().string());
return;
}
System.out.println(response.body().string());
}
}update
update builds the request that changes the name, the description, or the lock of the Release whose UID you passed to stack.releases().
| Name | Type | Description |
|---|---|---|
| requestBody (required) | JSONObject | Request body with the new details under a release key. |
| requestBody.release.name | String | Sets the new name of the Release. |
| requestBody.release.description | String | Sets the new description of the Release. |
| requestBody.release.locked | Boolean | true locks the Release, and false removes the lock. |
Returns: Call<ResponseBody>. The request for the updated Release, sent when you call execute().
Validation
- Throws IllegalAccessError if the Release has no UID or an empty UID, because the request path needs the Release UID.
- execute() throws IllegalArgumentException if requestBody is null, because Retrofit cannot build a request without a body.
- An API rejection does not throw. response.isSuccessful() is false and the error details are in response.errorBody().
Additional Resource Refer to Content Management API Errors for the full error code list.
Behavior
- One execute() sends one PUT /releases/{release_uid} request with requestBody as the JSON body. update sends no query parameters.
- The same request serves three API operations, by the body you send:
- name and description follow Update a Release.
- locked: true follows Lock a Release, which prevents further changes to the Release.
- locked: false removes the lock, as the request that removes a lock describes.
Example
Basic usage: rename a Release
import com.contentstack.cms.Contentstack;
import okhttp3.ResponseBody;
import org.json.simple.JSONObject;
import retrofit2.Response;
import java.io.IOException;
public class RenameRelease {
public static void main(String[] args) throws IOException {
Contentstack client = new Contentstack.Builder().build();
JSONObject release = new JSONObject();
release.put("name", "docs-test-release-renamed");
release.put("description", "Spring campaign pages, final set");
JSONObject requestBody = new JSONObject();
requestBody.put("release", release);
Response<ResponseBody> response = client.stack("<API_KEY>", "<MANAGEMENT_TOKEN>")
.releases("<RELEASE_UID>")
.update(requestBody)
.execute();
if (!response.isSuccessful()) {
// The API rejected the request. The body holds error_message, error_code and errors.
System.out.println("Request failed: " + response.code() + " " + response.errorBody().string());
return;
}
System.out.println(response.body().string());
}
}Lock a Release against further changes
import com.contentstack.cms.Contentstack;
import okhttp3.ResponseBody;
import org.json.simple.JSONObject;
import retrofit2.Response;
import java.io.IOException;
public class LockRelease {
public static void main(String[] args) throws IOException {
Contentstack client = new Contentstack.Builder().build();
JSONObject release = new JSONObject();
release.put("locked", true);
JSONObject requestBody = new JSONObject();
requestBody.put("release", release);
Response<ResponseBody> response = client.stack("<API_KEY>", "<MANAGEMENT_TOKEN>")
.releases("<RELEASE_UID>")
.update(requestBody)
.execute();
if (!response.isSuccessful()) { System.out.println(response.errorBody().string()); return; }
System.out.println(response.body().string());
}
}