July 29, 2019

The upgraded Reference field now allows you to add references to the entries of multiple content type. For example, the “Sample” Reference field in your “Demo” content type can refers to the “Content Type 1,” "Content Type 2", ... content types. So, while creating an entry for the “Demo” content type, the content manager can add any entry from the above mentioned content types as a reference to the “Sample” field.

This has an impact on some of the existing API Requests. They are as follows:

Create a content type

OLDNEW
Method: POST/PUTMethod: POST/PUT
URL: https://api.contentstack.io/v3/content_typesURL: https://api.contentstack.io/v3/content_types
Request Body

{

"content_type": {

"title": "Old content type",

"uid": "old_content_type",

"schema": [{

"display_name": "Title",

"uid": "title",

"data_type": "text"

"field_metadata": {

"_default": true

},

"unique": true,

"mandatory": true,

"multiple": true,

}, {

"data_type": "reference",

"display_name": "Reference",

"reference_to": "referred_content_type",

"field_metadata": {

"ref_multiple": true

},

"uid": "reference",

"mandatory": false,

"multiple": false,

"unique": false

}],

"options": {

"title": "title",

"publishable": true,

"is_page": false,

"singleton": false,

"sub_title": [],

"url_pattern": false,

"url_prefix": ""

}

}

}

Request Body

{

"content_type": {

"title": "Content Type With Multiple Content Type Referencing Field",

"uid": "content_type_with_multiple_content_type_referencing_field",

"schema": [{

"display_name": "Title",

"uid": "title",

"data_type": "text",

"field_metadata": {

"_default": true,

},

"unique": true,

"mandatory": true,

"multiple": true

}, {

"data_type": "reference",

"display_name": "Reference",

"reference_to": ["content_type_1", "content_type_2"],

"field_metadata": {

"ref_multiple_content_types": true,

"ref_multiple": true

},

"uid": "reference",

"mandatory": false,

"multiple": false,

"unique": false

}],

"options": {

"title": "title",

"publishable": true,

"is_page": false,

"singleton": false,

"sub_title": [],

"url_pattern": false,

"url_prefix": ""

}

}

}

Response Body

{

"notice": "Content Type updated successfully.",

"content_type": {

"title": "Old content type",

"uid": "Old_content_type",

"schema": [{

"display_name": "Title",

"uid": "title",

"data_type": "text",

"field_metadata": {

"_default": true

},

"unique": true,

"mandatory": true,

"multiple": false

}, {

"data_type": "reference",

"display_name": "Reference",

"reference_to": "referred_content_type",

"field_metadata": {

"ref_multiple": true

},

"uid": "reference",

"unique": false,

"mandatory": false,

"multiple": false

}],

"options": {

"title": "title",

"publishable": true,

"is_page": false,

"singleton": false,

"sub_title": [],

"url_pattern": false,

"url_prefix": ""

}

}

}

Response Body

{

"notice": "Content Type updated successfully.",

"content_type": {

"title": "Content Type With Multiple Content Type Referencing Field",

"uid": "content_type_with_multiple_content_type_referencing_field",

"schema": [{

"display_name": "Title",

"uid": "title",

"data_type": "text",

"field_metadata": {

"_default": true

},

"unique": true,

"mandatory": true,

"multiple": false

}, {

"data_type": "reference",

"display_name": "Reference",

"reference_to": ["content_type_1", "content_type_2"],

"field_metadata": {

"ref_multiple_content_types": true,

"ref_multiple": true

},

"uid": "reference",

"mandatory": false,

"multiple": false,

"unique": false

}],

"options": {

"title": "title",

"publishable": true,

"is_page": false,

"singleton": false,

"sub_title": [],

"url_pattern": false,

"url_prefix": ""

}

}

}

Create an entry

OLDNEW
Method: POST/PUTMethod: POST/PUT
URL: https://api.contentstack.io/v3/content_types/:content_type_uid/entries/:entry_uidURL: https://api.contentstack.io/v3/content_types/:content_type_uid/entries/:entry_uid
Request Body

{

"entry": {

"title": "Old Entry",

"uid": "old_entry",

"reference_field": ["blt1231232123123"],

"tags": []

}

}

Request Body

{

"entry": {

"title": "New Entry",

"uid": "new_entry",

"reference_field": [{

"uid": "blt111111111111",

"_content_type_uid": "footer"

}, {

"uid": "blt123123123123",

"_content_type_uid": "author"

}],

"tags":[]

}

Response Body

{

"notice": "Entry updated successfully."

"entry":{

"title": "Old Entry",

"uid": "old_entry",

"reference_field": ["blt123123123123"],

"tags": [],

"locale": "en-us",

"uid": "blt35a04ea07a42f95f",

"created_by": "blte75599b1e529fa3a",

"updated_by": "blte75599b1e529fa3a",

"created_at": "2019-01-09T10:03:25.096Z",

"updated_at": "2019-01-09T10:03:25.096Z",

"ACL": {},

"_version": 2

}

}

Response Body

{

"notice": "Entry updated successfully."

"entry":{

"title": "New Entry",

"uid": "new_entry",

"reference_field": [{

"uid": "blt111111111111",

"_content_type_uid": "footer"

}, {

"uid": "blt123123123123",

"_content_type_uid": "author"

}],

"tags": [],

"locale": "en-us",

"uid": "blt35a04ea07a42f95f",

"created_by": "blte75599b1e529fa3a",

"updated_by": "blte75599b1e529fa3a",

"created_at": "2019-01-09T10:03:25.096Z",

"updated_at": "2019-01-09T10:03:25.096Z",

"ACL": {},

"_version": 2

}

}

Get all entries of a content type

OLDNEW
Method: GETMethod: GET
URL: https://api.contentstack.io/v3/content_types/:content_type_uid/entriesURL: https://api.contentstack.io/v3/content_types/:content_type_uid/entries
CDN users: https://cdn.contentstack.io/v3/content_types/:content_type_uid/entriesCDN Users: https://cdn.contentstack.io/v3/content_types/:content_type_uid/entries
Response Body

{

"entries": [{

"title": "Old entry",

"reference_field": ["blt123123123123"],

"tags": [],

"locale": "en-us",

"uid": "blta777c7777777d777",

"created_by": "blt15adac31fdb46cd9",

"updated_by": "blt15adac31fdb46cd9",

"created_at": "2019-04-15T09:36:19.960Z",

"updated_at": "2019-04-15T09:36:19.960Z",

"ACL": {},

"_version": 1,

"publish_details": [],

"_rules": []

}]

}

Response Body

{

"entries":{

"title": "New Entry",

"reference_field": [{

"uid": "blt111111111111",

"_content_type_uid": "footer"

}, {

"uid": "blt123123123123",

"_content_type_uid": "author"

}],

"tags": [],

"locale": "en-us",

"uid": "blta777c7777777d777",

"created_by": "blte75599b1e529fa3a",

"updated_by": "blte75599b1e529fa3a",

"created_at": "2019-01-09T10:03:25.096Z",

"updated_at": "2019-01-09T10:03:25.096Z",

"ACL": {},

"_version": 2

}

}

Get all entries with include reference

OLDNEW
Method: GETMethod: GET
URL: https://api.contentstack.io/v3/content_types/:content_type_uid/entries?include[]=reference_fieldURL: https://api.contentstack.io/v3/content_types/:content_type_uid/entries?include[]=reference_field
CDN Users: https://cdn.contentstack.io/v3/content_types/:content_type_uid/entries?include[]=reference_fieldCDN Users: https://cdn.contentstack.io/v3/content_types/:content_type_uid/entries?include[]=reference_field
Response Body

{

"entries":[{

"title": "Old Entry",

"reference_field": [{

"title": "Forbes",

"about_us": {

"title": "About US",

"href": "/about-us"

},

"tags": [],

"locale": "en-us",

"uid": "blt1137fe73e677645f",

"ACL": {},

"_version": 1,

Response Body

{

"entries":[{

"title": "Old Entry",

"reference_field": [{

"title": "Forbes",

"about_us": {

"title": "About US",

"href": "/about-us"

},

"tags": [],

"locale": "en-us",

"uid": "blt1137fe73e677645f",

"_content_type_uid": "footer",

"ACL": {},

"_version": 1,

}],

"locale": "en-us",

"uid": "blta785c1339591d092",

"_version": 1

}]

}

Was this article helpful?

Thanks for your feedbackSmile-icon

^