Error when I try to create post via api
-
Hi, I’m re-posting In this section because I figure more people might be able to help me.
I’m trying to send a “POST” request via curl to my site, in order to create a new post.
My command:
curl -X POST --user "admin:admin" https://website.com/wp-json/wp/v2/posts/ -H "Content-Type: application/json" -d '{"title":"test","content":"Content","status":"draft"}'
My response:
{"code":"rest_invalid_json","message":"Invalid JSON body passed.","data":{"status":400,"json_error_code":4,"json_error_message":"Syntax error"}}
If I don’t use the header option I get:
{"code":"empty_content","message":"Content, title, and excerpt are empty.","data":{"status":400}}
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Error when I try to create post via api’ is closed to new replies.