When doing a POST request to create a new nested resource, its foreign key is parsed as string, as opposed to integer. This causes the parent to not recognize its child resource.
For example
POST /posts/1/images
BODY
{
url: âsome-urlâ
}
would yield a response
{
url: âsome-urlâ,
postId: â1â,
id: 1
}
So, when doing a GET request
GET /posts/1?_embed=images, the response is as follows
{
id: 1,
...,
images : [],
}
Essentially, the post doesnât recognize the image attached to it, because the foreign key is parsed as string.
Manually changing the foreign key into integer data type will work.
Any suggestion? Is this how itâs supposed to work?
Some existing comments that I found
Can this one be merged? We suffer from the same problem!
Same here. It's kind of a blocker when you are trying to mock POST methods.
Hoping this could get merged as well!
Would be great if we could get this merged.