Can't use body as an API ID

I'm trying to set a slice field API ID to "body" but the Prismic interface keeps forcing it to be "body1".

Is this because Prismic doesn't support "body" or because I have "body" somewhere else and it's not allowing a duplicate?

Hello,

Thanks for reaching out to us.

Prismic automatically gives body or body1 API ID to slices field. You might have body API ID already. You need to check different tabs too.

Thanks,
Priyanka

Hi @Priyanka,

I'm not sure I understand.

Do API IDs across slices have to have unique names?

Hi @Priyanka ,

I have just checked this again and confirmed. I have 2 slices:

Slice 1:

field name api id field type
title title title
body body richtext
image image image

Slice 2:

field name api id field type
title title title
body body richtext
image image image

I cannot use "body" as an API ID when creating these in "Build Mode".
Prismic always changes it to "body1".
"title" and "image" don't have this issue.

So is this a Prismic limitation?
Is this documented anywhere?

Hi @seanl

Here you can not use the body as an API ID of rich text field under slices because all Slices are stored by default in an array on the document object's data property called body. What you are giving is an API id of different fields under slices.

Please find complete detail in the What is a Slice article.

Let me know if it is still not clear to you.

Thanks,
Priyanka

Hi @Priyanka

Thanks for the reply.

Unfortunately I don't quite understand your reply.
I read the whole page here What Is a Slice? - Prismic but it does not say I cannot use "body" for the API ID of a field in a slice.

Below is an example of my Custom Type with 2 slices ("hero" and "banner").
I had to change the "body" field to "description".

{
  "Main" : {
    "uid" : {
      "type" : "UID",
      "config" : {
        "label" : "uid"
      }
    },
    "body" : {
      "type" : "Slices",
      "fieldset" : "Slice zone",
      "config" : {
        "labels" : { },
        "choices" : {
          "hero" : {
            "type" : "Slice",
            "fieldset" : "hero",
            "description" : "hero",
            "icon" : "call_to_action",
            "display" : "list",
            "non-repeat" : {
              "title" : {
                "type" : "StructuredText",
                "config" : {
                  "single" : "heading1,heading2,heading3,heading4,heading5,heading6",
                  "label" : "title"
                }
              },
              "description" : {
                "type" : "StructuredText",
                "config" : {
                  "multi" : "paragraph,preformatted,heading1,heading2,heading3,heading4,heading5,heading6,strong,em,hyperlink,image,embed,list-item,o-list-item,rtl",
                  "allowTargetBlank" : true,
                  "label" : "description"
                }
              }
            },
            "repeat" : {
              "button_label" : {
                "type" : "StructuredText",
                "config" : {
                  "single" : "heading1,heading2,heading3,heading4,heading5,heading6",
                  "label" : "button_label"
                }
              },
              "button_link" : {
                "type" : "Link",
                "config" : {
                  "label" : "button_link",
                  "select" : null,
                  "allowTargetBlank" : true
                }
              }
            }
          },
          "banner" : {
            "type" : "Slice",
            "fieldset" : "banner",
            "description" : "banner",
            "icon" : "cloud_download",
            "non-repeat" : {
              "title" : {
                "type" : "StructuredText",
                "config" : {
                  "single" : "heading1,heading2,heading3,heading4,heading5,heading6",
                  "label" : "title"
                }
              },
              "description" : {
                "type" : "StructuredText",
                "config" : {
                  "multi" : "paragraph,preformatted,heading1,heading2,heading3,heading4,heading5,heading6,strong,em,hyperlink,image,embed,list-item,o-list-item,rtl",
                  "allowTargetBlank" : true,
                  "label" : "description"
                }
              }
            },
            "repeat" : {
              "button_label" : {
                "type" : "StructuredText",
                "config" : {
                  "single" : "heading1,heading2,heading3,heading4,heading5,heading6",
                  "label" : "button_label"
                }
              },
              "button_link" : {
                "type" : "Link",
                "config" : {
                  "allowTargetBlank" : true,
                  "label" : "button_link",
                  "select" : null
                }
              }
            }
          }
        }
      }
    }
  }
}

Hello @seanl

As you can find, all Slices are stored by default in an array on the document object's data property called body. When you give the API ID of the rich text field as body, it considers it a duplicate API ID, and Duplicate API IDs automatically append a number at the end.

"body" : {
"type" : "Slices",
}

So, either you change the name of the data property body or the API ID of the rich text field. I'd suggest you change the API ID of the rich text field as you are already doing.

Thanks,
Priyanka