'What is the proper format for HTTP POST Dynamic Zone data with Strapi API?
I have a Strapi user collection that looks like this.
I am trying to use the API to create a new user with the "AdditionalInfo" dynamic zone filled with "StudentUserInfos" component.
What would my HTTP POST request Body look like? I can not find documentation or example on how to do it anywhere. I have tried:
{
"username" : "string",
"password" : "string",
"email" : "string",
"AdditionalInfo": [
{
"__component": "user-type.student-user",
"Address": "string",
"ParentsName": "string",
"ParentsPhoneNumber": "string",
"SchoolName": "string",
"OtherInfo": "string"
}]
It gives me a Bad Request response. What is the proper format for this? Can you please point me to an example?
Solution 1:[1]
After digging a little bit, you should send your JSON like this:
{
"...otherFields"
"industry": "61f83aa80f6439632bac3579",
"additional_info": [
{
"__component": "fields.seller-fields",
"country": {
"isoCode": "US",
"name": "United States"
},
"state": {
"isoCode": "CA",
"name": "California"
},
"year_established": 2022,
"size": "10000+"
}
]
}
Where "additional_info" is the name of the dynamic zone and "fields.seller-fields" the name of the component. I would recommend creating a dummy dynamic zone through Strapi GUI and then fetching it and seeing how dynamic zones are stored. (That's how I figured out the name of the component). Check the image below
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | MauD |