Skip to content

Question: Create relationship items through main request #209

@fabuhelow

Description

@fabuhelow

Hi All,

I have a question regarding to create item and relationship items.

The scenario:
I have created 2 tables "country" and "city". The relationship between country and city is oneToMany 1-N.

So, is it possible to use the POST Country API to create a new cities?

Curl Request example:

`
curl --location --request POST 'http://laravelnew:8888/api/v1/countries'
--header 'Accept: application/vnd.api+json'
--header 'Content-Type: application/vnd.api+json'
--data-raw '{
"data":
{
"type": "countries",
"attributes": {
"name": "Country A",
},
"relationships":{
"cities":{
"data":[{"name":"City A"},{"name":"City B"}]
}
}
}

}'
`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions