Hello,
I am testing creating catalog objects via Catalog API.
In the docs mentioned that request must have an object.Id
field that starts with #
.
Here is the request:
{
"idempotency_key": "83f15ab7-cbcb-4a9b-a8c7-c5e22660fbb3",
"object": {
"type": "CATEGORY",
"id": "#83f15ab7-cbcb-4a9b-a8c7-c5e22660fbb3",
"category_data": {
"name": null
}
}
}
But when I try to execute such request I get an error
{
"errors": [
{
"category": "INVALID_REQUEST_ERROR",
"code": "MISSING_REQUIRED_PARAMETER",
"detail": "Invalid object `#83f15ab7-cbcb-4a9b-a8c7-c5e22660fbb3`: [merchant_token=MLZG4XV5CXNST] Attribute name required.."
}
]
}
If I try to set object.Id
without #
then: "detail": "Object ID must be blank, start with '#', or match an existing object: ID=\"83f15ab7-cbcb-4a9b-a8c7-c5e22660fbb3\".",
If I try to leave it blank then: "detail": "Field must not be blank"
. But the API literary said that it is allowed to leave it blank.
I’m Square Dev AI, here to help answer your question!
Based on the information you’ve provided, the following documentation will help answer your question:
Additional Documentation
Delete Catalog Objects and Query Deleted Objects
Retrieve Catalog Objects
Work with Images
If this documentation helped you find a solution, please check the box indicating that this reply solves the problem.
Otherwise one of our Developer Advocates will provide additional assistance shortly.
The error message you’re seeing is due to the name
field in category_data
being set to null
. The name
field is required when creating a CATEGORY
type object. The id
field can indeed be left blank, start with #
, or match an existing object. However, the name
field in category_data
must contain a non-null value.
Here’s an example of a valid request:
{
"idempotency_key": "83f15ab7-cbcb-4a9b-a8c7-c5e22660fbb3",
"object": {
"type": "CATEGORY",
"id": "#83f15ab7-cbcb-4a9b-a8c7-c5e22660fbb3",
"category_data": {
"name": "Your Category Name"
}
}
}
In this example, replace “Your Category Name” with the name you want to assign to the category.
This answer was reviewed by @Bryan-Square.