ReleaseItem

View as Markdown

ReleaseItem

A release item is one entry or asset in a Release, with the action (publish or unpublish), version, and locale that the Release deploys. Use this class to

  • list the items of a Release
  • add one item or several items to a Release
  • update every item to its latest version
  • remove items from a Release, or move them to another Release

stack.releases("<RELEASE_UID>").item() returns a ReleaseItem for that Release. ReleaseItem has no public constructor.

NameTypeDescription
releaseUidStringUID of the Release. Pass it to stack.releases() before you call item().

addHeader

addHeader adds one request header to this release item object.

NameTypeDescription
key (required)String

Name of the header.

Default: Not applicable
value (required)String

Value of the header.

Default: Not applicable

Returns: ReleaseItem. The same release item object, 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 item object, and stays there for every later request.
  • The object starts with a copy of the headers of the Release that created it.

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 ListItemsV2 {
    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>")
                .item()
                .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 item object.

NameTypeDescription
headers (required)HashMap<String, String>

Header names mapped to their values.

Default: Not applicable

Returns: ReleaseItem. The same release item object, 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 item object, and stay there for every later request.
  • The object starts with a copy of the headers of the Release that created it.

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 ListBranchItems {
    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("<RELEASE_UID>")
                .item()
                .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 item object.

NameTypeDescription
key (required)String

Name of the query parameter.

Default: Not applicable
value (required)Object

Value of the query parameter, sent as its string form.

Default: Not applicable

Returns: ReleaseItem. The same release item object, 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

Example

Basic usage: include the branch of each item

import com.contentstack.cms.Contentstack;
import okhttp3.ResponseBody;
import retrofit2.Response;

import java.io.IOException;

public class ListItemsWithBranch {
    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>")
                .item()
                .addParam("include_branch", 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 item object.

NameTypeDescription
params (required)HashMap<String, Object>

Query parameter names mapped to their values.

Default: Not applicable

Returns: ReleaseItem. The same release item object, 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

Example

Basic usage: add query parameters from a map

import com.contentstack.cms.Contentstack;
import okhttp3.ResponseBody;
import retrofit2.Response;

import java.io.IOException;
import java.util.HashMap;

public class ListItemsWithParamMap {
    public static void main(String[] args) throws IOException {
        Contentstack client = new Contentstack.Builder().build();

        HashMap<String, Object> params = new HashMap<>();
        params.put("include_branch", true);

        Response<ResponseBody> response = client.stack("<API_KEY>", "<MANAGEMENT_TOKEN>")
                .releases("<RELEASE_UID>")
                .item()
                .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());
    }
}

create

create builds the request that adds one entry or asset to this Release.

NameTypeDescription
jsonBody (required)JSONObject

Request body with the item details under an item key.

Default: Not applicable
jsonBody.item.uid (required)String

UID of the entry or asset.

Default: Not applicable
jsonBody.item.version (required)Integer

Version of the entry or asset to deploy.

Default: Not applicable
jsonBody.item.content_type_uid (required)String

Content type UID of the entry, or built_io_upload for an asset.

Default: Not applicable
jsonBody.item.action (required)String

publish or unpublish.

Default: Not applicable
jsonBody.item.locale (required)String

Locale of the item.

Default: Not applicable

Returns: Call<ResponseBody>. The request that adds the item to the Release, sent when you call execute().

Validation

  • Throws IllegalAccessError if the Release UID is missing or empty, because the request path needs it.
  • execute() throws IllegalArgumentException if jsonBody 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 Add a single item to a Release request (POST /releases/{release_uid}/item) with jsonBody as the JSON body and the query parameters of this object.
  • To add an asset, set content_type_uid to built_io_upload, as the API reference states.
  • To add several items in one request, use the createMultiple method.

Example

Basic usage: add an entry to a Release

import com.contentstack.cms.Contentstack;
import okhttp3.ResponseBody;
import org.json.simple.JSONObject;
import retrofit2.Response;

import java.io.IOException;

public class AddEntryToRelease {
    public static void main(String[] args) throws IOException {
        Contentstack client = new Contentstack.Builder().build();

        JSONObject item = new JSONObject();
        item.put("uid", "<ENTRY_UID>");
        item.put("version", 1);
        item.put("content_type_uid", "<CONTENT_TYPE_UID>");
        item.put("action", "publish");
        item.put("locale", "<LOCALE>");
        JSONObject jsonBody = new JSONObject();
        jsonBody.put("item", item);

        Response<ResponseBody> response = client.stack("<API_KEY>", "<MANAGEMENT_TOKEN>")
                .releases("<RELEASE_UID>")
                .item()
                .create(jsonBody)
                .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());
    }
}

Add an asset to a Release

import com.contentstack.cms.Contentstack;
import okhttp3.ResponseBody;
import org.json.simple.JSONObject;
import retrofit2.Response;

import java.io.IOException;

public class AddAssetToRelease {
    public static void main(String[] args) throws IOException {
        Contentstack client = new Contentstack.Builder().build();

        JSONObject item = new JSONObject();
        item.put("uid", "<ASSET_UID>");
        item.put("version", 1);
        item.put("content_type_uid", "built_io_upload");
        item.put("action", "publish");
        item.put("locale", "<LOCALE>");
        JSONObject jsonBody = new JSONObject();
        jsonBody.put("item", item);

        Response<ResponseBody> response = client.stack("<API_KEY>", "<MANAGEMENT_TOKEN>")
                .releases("<RELEASE_UID>")
                .item()
                .create(jsonBody)
                .execute();
        if (!response.isSuccessful()) { System.out.println(response.errorBody().string()); return; }
        System.out.println(response.body().string());
    }
}

createMultiple

createMultiple builds the request that adds several entries and assets to this Release in one request.

NameTypeDescription
jsonBody (required)JSONObject

Request body with the item list under an items key.

Default: Not applicable
jsonBody.items (required)List<JSONObject>

Items to add, one object per entry or asset.

Default: Not applicable
jsonBody.items[].uid (required)String

UID of the entry or asset.

Default: Not applicable
jsonBody.items[].version (required)Integer

Version of the entry or asset to deploy.

Default: Not applicable
jsonBody.items[].content_type_uid (required)String

Content type UID of the entry, or built_io_upload for an asset.

Default: Not applicable
jsonBody.items[].action (required)String

publish or unpublish.

Default: Not applicable
jsonBody.items[].locale (required)String

Locale of the item.

Default: Not applicable

Returns: Call<ResponseBody>. The request that adds the items to the Release, sent when you call execute().

Validation

  • Throws IllegalAccessError if the Release UID is missing or empty, because the request path needs it.
  • execute() throws IllegalArgumentException if jsonBody 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 Add multiple items to a Release request (POST /releases/{release_uid}/items) with jsonBody as the JSON body and the query parameters of this object.
  • For an asset, set content_type_uid to built_io_upload.
  • To add items to a Release in a bulk job, use the addReleaseItems method of BulkOperation.

Example

Basic usage: add an entry and an asset to a Release

import com.contentstack.cms.Contentstack;
import okhttp3.ResponseBody;
import org.json.simple.JSONObject;
import retrofit2.Response;

import java.io.IOException;
import java.util.Arrays;

public class AddItemsToRelease {
    public static void main(String[] args) throws IOException {
        Contentstack client = new Contentstack.Builder().build();

        JSONObject entry = new JSONObject();
        entry.put("uid", "<ENTRY_UID>");
        entry.put("version", 1);
        entry.put("content_type_uid", "<CONTENT_TYPE_UID>");
        entry.put("action", "publish");
        entry.put("locale", "<LOCALE>");

        JSONObject asset = new JSONObject();
        asset.put("uid", "<ASSET_UID>");
        asset.put("version", 1);
        asset.put("content_type_uid", "built_io_upload");
        asset.put("action", "publish");
        asset.put("locale", "<LOCALE>");
        JSONObject jsonBody = new JSONObject();
        jsonBody.put("items", Arrays.asList(entry, asset));

        Response<ResponseBody> response = client.stack("<API_KEY>", "<MANAGEMENT_TOKEN>")
                .releases("<RELEASE_UID>")
                .item()
                .createMultiple(jsonBody)
                .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());
    }
}

delete

delete builds a remove-items request for this Release that carries no request body.

Returns: Call<ResponseBody>. The request to remove items from the Release without a body, sent when you call execute().

Validation

  • Throws IllegalAccessError if the Release UID is missing or empty, because the request path needs it.
  • 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 DELETE /releases/{release_uid}/items with the headers of this object. delete sends no query parameters and no body.
  • The Remove an item from a Release request takes the items to remove in the body. delete cannot name them. Use the deleteReleaseItems method to send the item list.

Example

Basic usage: send the remove request without a body

import com.contentstack.cms.Contentstack;
import okhttp3.ResponseBody;
import retrofit2.Response;

import java.io.IOException;

public class RemoveReleaseItemsNoBody {
    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>")
                .item()
                .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());
    }
}

deleteReleaseItem

deleteReleaseItem builds the request that removes one entry or asset from this Release.

NameTypeDescription
jsonBody (required)JSONObject

Request body with the item details under an item key.

Default: Not applicable
jsonBody.item.uid (required)String

UID of the entry or asset.

Default: Not applicable
jsonBody.item.version (required)Integer

Version of the entry or asset to deploy.

Default: Not applicable
jsonBody.item.content_type_uid (required)String

Content type UID of the entry, or built_io_upload for an asset.

Default: Not applicable
jsonBody.item.action (required)String

publish or unpublish.

Default: Not applicable
jsonBody.item.locale (required)String

Locale of the item.

Default: Not applicable

Returns: Call<ResponseBody>. The request that removes the item from the Release, sent when you call execute().

Validation

  • Throws IllegalAccessError if the Release UID is missing or empty, because the request path needs it.
  • execute() throws IllegalArgumentException if jsonBody 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 DELETE /releases/{release_uid}/item with jsonBody as the JSON body and the query parameters of this object.
  • The Releases reference does not list this single-item path. The deleteReleaseItems method sends the documented Delete multiple items from a Release request, which also accepts a list of one item.

Example

Basic usage: remove one entry from a Release

import com.contentstack.cms.Contentstack;
import okhttp3.ResponseBody;
import org.json.simple.JSONObject;
import retrofit2.Response;

import java.io.IOException;

public class RemoveOneItem {
    public static void main(String[] args) throws IOException {
        Contentstack client = new Contentstack.Builder().build();

        JSONObject item = new JSONObject();
        item.put("uid", "<ENTRY_UID>");
        item.put("version", 1);
        item.put("content_type_uid", "<CONTENT_TYPE_UID>");
        item.put("action", "publish");
        item.put("locale", "<LOCALE>");
        JSONObject jsonBody = new JSONObject();
        jsonBody.put("item", item);

        Response<ResponseBody> response = client.stack("<API_KEY>", "<MANAGEMENT_TOKEN>")
                .releases("<RELEASE_UID>")
                .item()
                .deleteReleaseItem(jsonBody)
                .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());
    }
}

deleteReleaseItems

deleteReleaseItems builds the request that removes the entries and assets you list from this Release.

NameTypeDescription
jsonBody (required)JSONObject

Request body with the item list under an items key.

Default: Not applicable
jsonBody.items (required)List<JSONObject>

Items to remove, one object per entry or asset.

Default: Not applicable
jsonBody.items[].uid (required)String

UID of the entry or asset.

Default: Not applicable
jsonBody.items[].version (required)Integer

Version of the entry or asset to deploy.

Default: Not applicable
jsonBody.items[].content_type_uid (required)String

Content type UID of the entry, or built_io_upload for an asset.

Default: Not applicable
jsonBody.items[].action (required)String

publish or unpublish.

Default: Not applicable
jsonBody.items[].locale (required)String

Locale of the item.

Default: Not applicable

Returns: Call<ResponseBody>. The request that removes the items from the Release, sent when you call execute().

Validation

  • Throws IllegalAccessError if the Release UID is missing or empty, because the request path needs it.
  • execute() throws IllegalArgumentException if jsonBody 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 Delete multiple items from a Release request (DELETE /releases/{release_uid}/items) with jsonBody as the JSON body and the query parameters of this object.
  • The API reference lists an all query parameter for this request. Add all=true with addParam to remove every item of the Release at once.

Example

Basic usage: remove one entry from a Release

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 RemoveEntryFromRelease {
    public static void main(String[] args) throws IOException {
        Contentstack client = new Contentstack.Builder().build();

        JSONObject item = new JSONObject();
        item.put("uid", "<ENTRY_UID>");
        item.put("version", 1);
        item.put("content_type_uid", "<CONTENT_TYPE_UID>");
        item.put("action", "publish");
        item.put("locale", "<LOCALE>");
        JSONObject jsonBody = new JSONObject();
        jsonBody.put("items", Collections.singletonList(item));

        Response<ResponseBody> response = client.stack("<API_KEY>", "<MANAGEMENT_TOKEN>")
                .releases("<RELEASE_UID>")
                .item()
                .deleteReleaseItems(jsonBody)
                .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());
    }
}

Remove every item from a Release

import com.contentstack.cms.Contentstack;
import okhttp3.ResponseBody;
import org.json.simple.JSONObject;
import retrofit2.Response;

import java.io.IOException;

public class RemoveAllReleaseItems {
    public static void main(String[] args) throws IOException {
        Contentstack client = new Contentstack.Builder().build();

        JSONObject jsonBody = new JSONObject();

        Response<ResponseBody> response = client.stack("<API_KEY>", "<MANAGEMENT_TOKEN>")
                .releases("<RELEASE_UID>")
                .item()
                .addParam("all", true)
                .deleteReleaseItems(jsonBody)
                .execute();
        if (!response.isSuccessful()) { System.out.println(response.errorBody().string()); return; }
        System.out.println(response.body().string());
    }
}

find

find builds the request that lists the entries and assets in this Release.

Returns: Call<ResponseBody>. The request for the items of the Release, sent when you call execute().

Validation

  • Throws IllegalAccessError if the Release UID is missing or empty, because the request path needs it.
  • 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 items in a Release request (GET /releases/{release_uid}/items) with the headers and query parameters of this object.
  • The API reference lists include_branch as a query parameter for this request. Add it with addParam.
  • The response body is the raw JSON of the API. Read it with response.body().string().

Example

Basic usage: list the items of a Release

import com.contentstack.cms.Contentstack;
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();

        Response<ResponseBody> response = client.stack("<API_KEY>", "<MANAGEMENT_TOKEN>")
                .releases("<RELEASE_UID>")
                .item()
                .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());
    }
}

All options: include the branch of each item

import com.contentstack.cms.Contentstack;
import okhttp3.ResponseBody;
import retrofit2.Response;

import java.io.IOException;

public class ListReleaseItemsWithBranch {
    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>")
                .item()
                .addParam("include_branch", true)
                .find()
                .execute();
        if (!response.isSuccessful()) { System.out.println(response.errorBody().string()); return; }
        System.out.println(response.body().string());
    }
}

move

move builds the request that moves entries and assets from this Release to another Release.

NameTypeDescription
jsonBody (required)JSONObject

Request body with the items to move and the target Release.

Default: Not applicable

Returns: Call<ResponseBody>. The request that moves the items to another Release, sent when you call execute().

Validation

  • Throws IllegalAccessError if the Release UID is missing or empty, because the request path needs it.
  • execute() throws IllegalArgumentException if jsonBody 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 POST /releases/{release_uid}/items/move with jsonBody as the JSON body and the query parameters of this object.
  • The request path starts at the host root, so the request goes to https://<host>/releases/{release_uid}/items/move, without the /v3 segment that every other request carries.
  • The Releases reference does not list a move request.

Example

Basic usage: build a move request

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 MoveReleaseItems {
    public static void main(String[] args) throws IOException {
        Contentstack client = new Contentstack.Builder().build();

        JSONObject item = new JSONObject();
        item.put("uid", "<ENTRY_UID>");
        item.put("version", 1);
        item.put("content_type_uid", "<CONTENT_TYPE_UID>");
        item.put("action", "publish");
        item.put("locale", "<LOCALE>");
        JSONObject jsonBody = new JSONObject();
        jsonBody.put("items", Collections.singletonList(item));

        Response<ResponseBody> response = client.stack("<API_KEY>", "<MANAGEMENT_TOKEN>")
                .releases("<RELEASE_UID>")
                .item()
                .move(jsonBody)
                .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 item object.

NameTypeDescription
key (required)String

Name of the query parameter to remove.

Default: Not applicable

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.ReleaseItem;
import okhttp3.ResponseBody;
import retrofit2.Response;

import java.io.IOException;

public class RemoveItemParam {
    public static void main(String[] args) throws IOException {
        Contentstack client = new Contentstack.Builder().build();
        ReleaseItem items = client.stack("<API_KEY>", "<MANAGEMENT_TOKEN>").releases("<RELEASE_UID>").item();

        items.addParam("include_branch", true);
        // The next request sends no query parameters
        items.removeParam("include_branch");

        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());
    }
}

update

update builds the request that updates every entry and asset in this Release to its latest version.

NameTypeDescription
jsonBody (required)JSONObject

Request body {"items": ["$all"]}.

Default: Not applicable
jsonBody.items (required)List<String>

The list ["$all"], which selects every item.

Default: Not applicable

Returns: Call<ResponseBody>. The request that updates the items to their latest versions, sent when you call execute().

Validation

  • Throws IllegalAccessError if the Release UID is missing or empty, because the request path needs it.
  • execute() throws IllegalArgumentException if jsonBody 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 Update Release items to their latest versions request (PUT /releases/{release_uid}/update_items) with jsonBody as the JSON body and the query parameters of this object.
  • The API updates all items together. It cannot update a single item.
  • When you localize an entry after you add it to the Release, the update moves the item to the latest localized version.

Example

Basic usage: update every item to its latest version

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 UpdateReleaseItems {
    public static void main(String[] args) throws IOException {
        Contentstack client = new Contentstack.Builder().build();

        // "$all" is the only value the API accepts. It updates every item.
        JSONObject jsonBody = new JSONObject();
        jsonBody.put("items", Collections.singletonList("$all"));

        Response<ResponseBody> response = client.stack("<API_KEY>", "<MANAGEMENT_TOKEN>")
                .releases("<RELEASE_UID>")
                .item()
                .update(jsonBody)
                .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());
    }
}