Entry

View as Markdown

Entry

An entry is the actual piece of content created using one of the defined content types.

exceptWithReferenceUid()

The exceptWithReferenceUid method specifies an array of except keys that gets excluded from the response.

NameTypeDescription
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.<span>exceptWithReferenceUid</span>()

ArrayList<String> array = new ArrayList<String>();

<span>array.add("description");</span>

<span>array.add("name");</span>

<span>entry.onlyWithReferenceUid(array, "referenceUid");</span>

onlyWithReferenceUid

The onlyWithReferenceUid method specifies an array of reference UIDs that should be included in the response.

NameTypeDescription
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");

only

The only method specifies an array of keys in the base object to include in the response.

NameTypeDescription
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"});

includeReference

The includeReference method adds a constraint that requires the details of a specified reference key.

NameTypeDescription
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"});

except

The except method specifies an array of field UIDs that are excluded from the response.

NameTypeDescription
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"});

setLocale

The setLocale method sets the language of the entry.

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

getLocale

The getLocale method retrieves the locale of the entry, indicating the language of the content.

import com.contentstack.sdk.*;


Stack stack = Contentstack.stack(

apiKey, deliveryToken, environment);

final Entry entry = stack.contentType("contentType").entry("entryUid");

Entry entry = entry.getLocale();

getUid

The getUid method retrieves the UID 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.getUid()

getContentType

The getContentType method retrieves the content type 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.getContentType()

getTags

The getTags method retrieves the tags associated with the entry.

import com.contentstack.sdk.*;


Stack stack = Contentstack.stack(

apiKey, deliveryToken, environment);

final Entry entry = stack.contentType("contentType").entry("entryUid");

Entry entry = entry.<span>getTags</span>()

removeHeader

The removeHeader method removes a header associated with the specified key.

NameTypeDescription
keyString

key of the header you want to remove

import com.contentstack.sdk.*;


Stack stack = Contentstack.stack(<span>context, </span>apiKey, deliveryToken, environment);

final Entry entry = stack.contentType("contentType").entry("entryUid");

Entry entry = entry.removeHeader(key);

setHeader

The setHeader method adds a header using the specified key and value.

NameTypeDescription
keyString

key of the header you want to remove

value (required)String

value of the header against the key

import com.contentstack.sdk.*;


Stack stack = Contentstack.stack(

apiKey, deliveryToken, environment);

final Entry entry = stack.contentType("contentType").entry("entryUid");

Entry entry = entry.setHeader(key, value)

fetch

The fetch method retrieves the entry using its UID, and can optionally include query parameters to refine the response.

NameTypeDescription
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

The addParam method adds query parameters to the entry request to filter the response.

NameTypeDescription
key (required)String

key of the header

value (required)String

value of the header

import com.contentstack.sdk.*;


Stack stack = Contentstack.stack(<span>context, </span>apiKey, deliveryToken, environment);

final Entry entry = stack.contentType("contentType").entry("entryUid");

entry.addParam(key, value)

includeReferenceContentTypeUID

The includeReferenceContentTypeUID method includes the content type UIDs of referenced entries in the entry response.

import com.contentstack.sdk.*;


Stack stack = Contentstack.stack(<span>context, </span>apiKey, deliveryToken, environment);

final Entry entry = stack.contentType("contentType").entry("entryUid");

entry.includeReferenceContentTypeUID()

includeContentType

The includeContentType method includes the content type UID of the entry.

import com.contentstack.sdk.*;


Stack stack = Contentstack.stack(<span>context, </span>apiKey, deliveryToken, environment);

final Entry entry = stack.contentType("contentType").entry("entryUid");

entry.includeContentType()

includeFallback

The includeFallback method includes the fallback language content in the entry response when the specified locale content is unavailable.

import com.contentstack.sdk.*;


Stack stack = Contentstack.stack(<span>context, </span>apiKey, deliveryToken, environment);

final Entry entry = stack.contentType("contentType").entry("entryUid");

entry.includeFallback()

includeEmbeddedItems

The includeEmbeddedItems method includes embedded items in the entry response.

import com.contentstack.sdk.*;


Stack stack = Contentstack.stack(<span>context, </span>apiKey, deliveryToken, environment);

final Entry entry = stack.contentType("contentType").entry("entryUid");

entry.includeEmbeddedItems()

includeBranch

The includeBranch method includes the branch information in the entry response.

import com.contentstack.sdk.*;


Stack stack = Contentstack.stack(<span>context, </span>apiKey, deliveryToken, environment);

final Entry entry = stack.contentType("user").entry("entryUid");

entry.includeBranch();

includeMetadata

The includeMetadata method includes the entry metadata along with the response body.

Stack stack = Contentstack.stack(context, "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-uid header.

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

         }

 });