Label

View as Markdown

Label

Labels allow you to group a collection of content within a stack. Using labels, you can group content types that need to work together.

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.

addParam

Sets header for the request.

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

Label label = contentstack.stack().label();

response = label.addParam("key", value);

addHeader

Sets header for the request.

NameTypeDescription
key (required)String
Header key for the request.
value (required)Object
Header value for the request.
import contentstack;

Contentstack contentstack = new Contentstack.Builder().build();

Label label = contentstack.stack().label();

label.addHeader("key", value);

addBranch

Enter your branch's unique ID.

NameTypeDescription
value (required)Object
Branch's unique ID.
import contentstack;

Contentstack contentstack = new Contentstack.Builder().build();

Label label = contentstack.stack().label();

response = label.addBranch(value);

removeParam

Set header for the request.

NameTypeDescription
key (required)String

Removes query parameters using the key of the request.

import contentstack;

Contentstack contentstack = new Contentstack.Builder().build();

Label label = contentstack.stack().label();

label.removeParam("key");

delete

The "Delete label" call is used to delete a specific label.

When executing the API call, under the 'Header' section, you need to enter the authtoken that you receive after logging into your account

import contentstack;

Contentstack contentstack = new Contentstack.Builder().build();

Label label = contentstack.stack().label();

Call<ResponseBody> response = label.delete().execute();

if (response.isSuccessful) {

    System.out.println("Response" + response);

}

update

The "Update label" call is used to update an existing label.

When executing the API call, under the 'Header' section, you need to enter the authtoken that you receive after logging into your account.

NameTypeDescription
requestBody (required)JSONObject

The request body to update the Label.

import contentstack;

Contentstack contentstack = new Contentstack.Builder().build();

Label label = contentstack.stack().label();

Call<ResponseBody> response = label.update(requestBody).execute();

if (response.isSuccessful) {

    System.out.println("Response" + response);

}

find

The "Find label" call fetches all the existing labels of the stack.

When executing the API call, under the Header section, you need to enter the API key of your stack and the authtoken that you receive after logging into your account.

Using addParam(String, Object), you can add queries to extend the functionality of this API call. Under the URI Parameters section, insert a parameter named query and provide a query in JSON format as the value.

import contentstack;

Contentstack contentstack = new Contentstack.Builder().build();

Label label = contentstack.stack().label();

Call<ResponseBody> response = label.find().execute();

if (response.isSuccessful) {

    System.out.println("Response" + response);

}

fetch

The "Get label" call returns information about a particular label of a stack.

import contentstack;

Contentstack contentstack = new Contentstack.Builder().build();

Label label = contentstack.stack().label();

Call<ResponseBody> response = label.fetch().execute();

if (response.isSuccessful) {

    System.out.println("Response" + response);

}

create

This call is used to create a label.

When executing the API call, under the 'Header' section, you need to enter the API key of your stack and the authtoken that you receive after logging into your account.

NameTypeDescription
body (required)JSONObject

The request body.

import contentstack;

Contentstack contentstack = new Contentstack.Builder().build();

Label label = contentstack.stack().label();

Call<ResponseBody> response = label.create(body).execute();

if (response.isSuccessful) {

    System.out.println("Response" + response);

}