When I POST using the simple setup described on the project page, the post creates a new id, but does not add the title and author I specify in the JSON body.
I do a POST to: http://localhost:3000/posts
Body is: { "title": "hello world", "author": "typicode" }
Result is HTTP 201, with body: { "id": 2 }
db.json shows id 2, but that's it
What am I missing?
make sure you set content-type request header to application/json
It is set to application/json. The server responds 201, creates the post
record, and gives it the next available id. It just fails to create the
title and author field.
On Mon, Jan 15, 2018, 9:39 PM Ahmed Ayoub notifications@github.com wrote:
make sure you set content-type header to application/json
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/typicode/json-server/issues/711#issuecomment-357837530,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AJ86-vO1A4753gGcGoflUCQM_zXUN9Ndks5tLAv9gaJpZM4Re5Ch
.
Got it. You're right, the content-type was not being set correctly. Thank you for the quick response.
@BrianKrohn, how did you add the Content-Type? I have added it on my test, but I still seem to be only able to post IDs. I'm not too sure if I need to associate it with the POST test?
Please see issue https://github.com/typicode/json-server/issues/821
Don't worry guys, I had incorrectly added the HTTP Header Manager. Thanks 👍 :)
i had the same problem, found the solution here https://www.youtube.com/watch?v=FyZBTbv7UM0
Most helpful comment
make sure you set
content-typerequest header toapplication/json