Skip to content

[TEST] [Bug]: How to create data with collection have dynamic inside #2527

Closed
@pwizla

Description

@pwizla

Link to the documentation page or resource

https://docs.strapi.io/dev-docs/api/rest

Describe the bug

Hi, I am developing CMS to manage content. I have a collection containing dynamic zones. When I create data with REST API, I get the issue:

  • if I add __component then I get error 400 - Invalid key __component
  • if I don't add __component then I get error 400 - messages[0].__component is a required field
    I want to know. How to create data have dynamic zone with REST API?
    strapi version: 5.5.0
    node: 18.19.0

Additional context

curl --location 'http://localhost:1337/api/prompts' \ --header 'Content-Type: application/json' \ --data '{ "data": { "messages": [ { "contents": [ { "text": "[Completed Task: -1]\nHi there! What can I get for you today?\n[Next Task: 1]" } ], "role": "assistant" } ], } }'

Image

curl --location 'http://localhost:1337/api/prompts' \ --header 'Content-Type: application/json' \ --data '{ "data": { "messages": [ { "contents": [ { "text": "[Completed Task: -1]\nHi there! What can I get for you today?\n[Next Task: 1]" } ], "__component": "prompt.message-text", "role": "assistant" } ], } }'

Image

curl --location 'http://localhost:1337/api/prompts' \ --header 'Content-Type: application/json' \ --data '{ "data": { "messages": [ { "contents": [ { "text": "[Completed Task: -1]\nHi there! What can I get for you today?\n[Next Task: 1]" } ], "__component": "", "role": "assistant" } ], } }'

Image

Suggested improvements or fixes
No response

Related issue(s)/PR(s)
No response

Suggested improvements or fixes

No response

Related issue(s)/PR(s)

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions