Alias

View as Markdown

Alias

An alias acts as a pointer to a particular branch. You can specify the alias ID in your frontend code to pull content from the target branch associated with an alias.

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

Alias alias = contentstack.stack().alias();

alias.addHeader("key", value)

addParam

Sets params 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();

Alias alias = contentstack.stack().alias();

alias.addParam("key", value);

removeParam

Set header for the request.

NameTypeDescription
key (required)String

Removes query parameter using a key of request.

import contentstack; 

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

Alias alias = contentstack.stack().alias();

alias.removeParam("key");

find

The "Get all aliases" request returns comprehensive information about all the aliases available in a particular stack in your account.

import contentstack; 


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

Alias alias = contentstack.stack().alias();

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

if (response.isSuccessful){ 

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

}

fetch

The "Get a single alias" request returns information about a specific alias.

import contentstack; 


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

Alias alias = contentstack.stack().alias();

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

if (response.isSuccessful){ 

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

}

update

The "Assign an alias" request creates a new alias in a particular stack of your organization. This alias can point to any existing branch (target branch) of your stack.

NameTypeDescription
body (required)JSONObject

The request body to update the Alias.

import contentstack; 


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

Alias alias = contentstack.stack().alias();

Call<ResponseBody> response = alias.update(body).execute();

if (response.isSuccessful){ 

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

}

delete

The "Delete an alias" request deletes an existing alias.

To confirm the deletion of an alias, you need to specify the force=true query parameter.

When executing the API call, in the “URL Parameters” section, provide the UID of your alias.

import contentstack; 


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

Alias alias = contentstack.stack().alias();

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

if (response.isSuccessful){ 

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

}