Entry
Entry
An entry is the actual piece of content created using one of the defined content types.
removeHeader
Removes header using key
| Name | Type | Description |
|---|---|---|
| key | String | key of the header you want to remove |
import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
final Entry entry = stack.contentType("contentType").entry("entryUid");
Entry entry = entry.removeHeader(key)getTags
Gets entry tags
import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
final Entry entry = stack.contentType("contentType").entry("entryUid");
Entry entry = entry.
()getContentType
Gets entry content type
import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
final Entry entry = stack.contentType("contentType").entry("entryUid");
Entry entry = entry.getContentType()getUid
Gets entry uid
import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
final Entry entry = stack.contentType("contentType").entry("entryUid");
Entry entry = entry.getUid()getLocale
Gets Language of the entry
import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
final Entry entry = stack.contentType("contentType").entry("entryUid");
Entry entry = entry.getLocale();setLocale
Sets locale of entry
| Name | Type | Description |
|---|---|---|
| locale (required) | String | language code |
import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
final Entry entry = stack.contentType("contentType").entry("entryUid");
Entry entry = entry.setLocale("locale_code");except
Specifies list of field uids that would be excluded from the response
| Name | Type | Description |
|---|---|---|
| referenceField (required) | String | field uid which get excluded from the response. |
import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
final Entry entry = stack.contentType("contentType").entry("entryUid");
entry.except(new String[]{"name", "description"});includeReference
Add a constraint that requires a particular reference key details.
| Name | Type | Description |
|---|---|---|
| referenceFields (required) | String[] | referenceFields array key that to be constrained |
import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
final Entry entry = stack.contentType("contentType").entry("entryUid");
entry.includeReference(new String[]{"referenceUid_A", "referenceUid_B"});only
Specifies an array of only keys in BASE object that would be included in the response
| Name | Type | Description |
|---|---|---|
| fieldUid (required) | ArrayList<String> | Array of the only reference keys to be included in response |
import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
final Entry entry = stack.contentType("contentType").entry("entryUid");
entry.only(new String[]{"name", "description"});onlyWithReferenceUid
Specifies an array of only keys that would be included in the response.
| Name | Type | Description |
|---|---|---|
| fieldUid (required) | ArrayList<String> | Array of the only reference keys to be included in response. |
| referenceFieldUid (required) | String | Key who has reference to some other class object |
import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
final Entry entry = stack.contentType("contentType").entry("entryUid");
ArrayList<String> array = new ArrayList<String>();
array.add("description");
array.add("name");
entry.onlyWithReferenceUid(array, "referenceUid");exceptWithReferenceUid()
Specifies an array of except keys that would be exclude in the response
| Name | Type | Description |
|---|---|---|
| fieldUid (required) | ArrayList<String> | Array of the except reference keys to be excluded in response |
| referenceFieldUid (required) | String | Key who has reference to some other class object |
import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
final Entry entry = stack.contentType("contentType").entry("entryUid");
entry.
()
ArrayList<String> array = new ArrayList<String>();fetch
fetch is used to get the entry response
| Name | Type | Description |
|---|---|---|
| callback (required) | EntryResultCallBack | EntryResultCallBack object to notify the application when the request has completed |
import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
final Entry entry = stack.contentType("contentType").entry("entryUid");
entry.fetch(new EntryResultCallBack() {
@Override public void onCompletion(ResponseType responseType, Error error) {
}
});}addParam
Adds query parameters in the entry request
These are the keys that can be passed for addParam.
| Key | Value | Description |
|---|---|---|
| include_fallback | boolean | Enter true to include published localized content from the fallback locale when the specified locale lacks published content. |
locale | string | Enter the language code for which you want to include entries. Only published, localized entries will be displayed. |
include_branch | boolean | Set to true to include the _branch top-level key in the response. This key indicates the unique ID of the branch where the specified Contentstack module resides. |
version | number | Enter the latest version number. Providing a draft version number will result in an empty response. |
| Name | Type | Description |
|---|---|---|
| key (required) | String | key of the header |
| value (required) | String | value of the header |
import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
final Entry entry = stack.contentType("contentType").entry("entryUid");
entry.addParam(key, value)includeReferenceContentTypeUID
Include Reference ContentType UID in the entry response
import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
final Entry entry = stack.contentType("contentType").entry("entryUid");
entry.includeReferenceContentTypeUID()includeContentType
Include ContentType in the entry response
import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
final Entry entry = stack.contentType("contentType").entry("entryUid");
entry.includeContentType()includeFallback
Include Fallback Language in the entry response
import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
final Entry entry = stack.contentType("contentType").entry("entryUid");
entry.includeFallback()includeEmbeddedItems
Include Embedded Items in the entry response
import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
final Entry entry = stack.contentType("contentType").entry("entryUid");
entry.includeEmbeddedItems()includeBranch
include branch in the entry response
import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
final Entry entry = stack.contentType("user").entry("entryUid");
entry.includeBranch();includeMetadata
Includes entry metadata along with response body.
Stack stack = Contentstack.stack("apiKey", "deliveryToken", environment_name);
Entry entry = stack.contentType("contentTypeUid").entry("entryUid")
entry.includeMetadata();variants
The variants method retrieves details of a specific entry variant or an array of entry variants based on the applied query.
When Personalize creates a variant in the CMS, it assigns a "Variant Alias" to identify that specific variant. When fetching entry variants using the Delivery API, you can pass variant aliases in place of variant UIDs in the x-cs-variant-uidheader.
| Name | Type | Description |
|---|---|---|
| variantUid/variantAlias (required) | string / string[] | Enter the UID/Alias of the variant |
Example 1:
import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
final Entry entry = stack
.contentType("contentType")
.entry("entryUid")
.variants("variantUid/variantAlias");
entry.fetch(new EntryResultCallBack() {
@Override
public void onCompletion(ResponseType responseType, Error error) {
System.out.println(entry.toJSON());
}
});Example 2:
import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
final Entry entry = stack
.contentType("contentType")
.entry("entryUid")
.variants(new String[]{"variantUid1/variantAlias1","variantUid2/variantAlias2"});
entry.fetch(new EntryResultCallBack() {
@Override
public void onCompletion(ResponseType responseType, Error error) {
System.out.println(entry.toJSON());
}
});assetFields
The assetFields method acts as a filter for the API response, ensuring you get exactly the asset metadata you need. It specifies the asset-related field groups to include in the API response when you fetch a single entry.
Note The assetFields method is supported only in the North America (NA) region.
| Name | Type | Description |
|---|---|---|
| fields | String... (varargs) | One or more asset field groups to include in the response. |
Supported values
- user_defined_fields: Custom metadata and other user-defined asset fields for assets included with this entry.
- embedded: Embedded asset payload for assets referenced from this entry
- ai_suggested: AI-suggested asset metadata where applicable for assets in this entry.
- visual_markups: Visual markup data for assets referenced from this entry.
Behavior:
- Multiple calls: The last call overrides previous values.
- No arguments or null: Omits the asset_fields[] parameter; the API returns default fields.
Fetch a single entry with specific asset fields.
Use this when you know the entry UID and want to fetch its assets.
import com.contentstack.sdk.*;
Stack stack = Contentstack.stack("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");
Entry entry = stack
.contentType("blog_post")
.entry("entry_uid")
.assetFields("user_defined_fields", "embedded", "ai_suggested", "visual_markups");
entry.fetch(new EntryResultCallBack() {
@Override
public void onCompletion(ResponseType responseType, Error error) {
if (error == null) {
// Use entry data
} else {
// Handle error
}
}
});Query multiple entries with asset fields
Use this when fetching a list of entries (e.g., a blog feed) to ensure all returned entries include the specified asset metadata.
import com.contentstack.sdk.*;
Stack stack = Contentstack.stack("<API_KEY>", "<DELIVERY_TOKEN>", "<ENVIRONMENT>");
Query query = stack
.contentType("blog_post")
.query()
.assetFields("user_defined_fields", "embedded");
query.find(new QueryResultsCallBack() {
@Override
public void onCompletion(ResponseType responseType, QueryResult queryResult, Error error) {
if (error == null) {
// Use queryResult.getResultObjects() for the list of entries
} else {
// Handle error
}
}
});