Every time I try to create an order via /api/order it gives me 400 (Bad request), there doesn’t seem to be a proper clear explanation anywhere on how to create records with relational fields, the only one I found close to what I needed was this:
So supposedly I should use an id or a list of ids depending on the type of relation, but it still gives me 400 Bad request with no explanation in the response.
My order content-type looks like this:
User is a Many-to-One relationship, so a user can have many orders, but there can only be one user per order, and products is One-to-Many, so an order can have many products
This is what my API call looks like:
await axios.post(
`${baseUrl}/api/orders`,
{
products: [9],
total: 320,
user: 42
}
);
The products and user ids are exactly the ones I have in the database and authentication is not the problem.
Please help me understand what I’m doing wrong and how I should be creating records with relational fields. Thanks