That’s strange, but nonetheless, you should know that whether you use cURL, PHP, JS, etc., if you’re sending a JSON data, then you should set the Content-Type
header to application/json
.
And via the cURL command line, you can use the -H
option:
curl --user "username:password" -X POST \
-H "Content-Type: application/json" \
-i https://example.com/wp-json/wp/v2/posts \
-d '{"title": "foo bar", "content": "test"}'
Also, if you’re using Windows, you may need to use the double quotes instead of single quotes with the -d
option. So the above would be: ( note I used the caret (^
) symbol and not backslash )
curl --user "username:password" -X POST ^
-H "Content-Type: application/json" ^
-i https://example.com/wp-json/wp/v2/posts ^
-d "{\"title\": \"Windows test\", \"content\": \"test\"}"
Related Posts:
- WP Rest API v2 filter and display latest post with specific tag
- Disable REST API for a user ROLE
- ping_status in JSON REST API
- WordPress REST API not returning all posts
- Optimal WP Web App Backend for mobile app development
- exclude particular category in api
- Loading posts outside wordpress
- How to create REST Based JSON API(how to modify the code below)?
- How to add category to: ‘wp-admin/post-new.php’?
- Fetch All Posts (Including Those Using a Custom Post Type) With WordPress API
- WP REST API, query total posts in a category
- JSON not valid after json_encode posts
- Get post from custom REST endpoint in Gutenberg
- WordPress Rest API – Get all posts based on post_meta on custom endpoint
- WordPress blog posts api – get posts by author
- How to automate filing a form as a user
- WP rest api returns 404 only when author param is used
- Create a WordPress post using curl comand from Linux console?
- Create post using JSON api plugin
- Exclude posts w/ specific post_meta on Rest API endpoint
- Add ajax load more function using WP API
- Transfer WordPress post to RoR site: is the REST Api the only and/or best solution?
- JSON – Permission Error?
- Exclude post_meta from Rest API Endpoint
- WP Remote Request not returning all of content via request
- Get more than one author’s posts with REST API
- How can I get the media inside a post?
- WordPress Rest API Create Post
- XML-code sent via the POST method to the URL (API) [closed]
- How to disable WordPress blog folder
- Call Web Services on post first publish
- Getting featured image with PHP and not javascript from wordpress api _embed [closed]
- search blog posts by author first name and or last name
- Creating a WordPress Post via REST API – HTML or Markdown?
- How to get post with associated categories and tags names instead of ids with rest api?
- What date to use as a post date? date_gmt or modified_date_gmt
- Custom wp-query in wordpress rest api
- Filter out posts based on a certain post_meta on the WordPress REST API
- Delete Post but retain image of post [WP REST API]
- Pull in posts using post meta for REST API
- Rest API Paginate until all posts are imported
- Format array of objects to json for wp-json
- Add a field in my rest api
- How do I assign an attachment to a post using only the REST API?
- WordPress rest API get Posts parent by post ID
- Updating post status via rest api
- Weird problem occurs while using WordPress REST API to create new post
- How to set the post permalink using the WordPress REST API?
- How to prevent post update using transition_post_status
- REST API Working for GET but not for POST?
- Best Way to detect unique posts in wp rest api
- Authentication over CURL
- Is it possible to make WordPress as a RESTful app?
- Adding a time stamp on post view
- WP Rest API feature image breaking react component
- Changes done in admin panel are taking time to reflect in the REST api responses
- Access post from post id in URL
- How to mark articles as read?
- WooCommerce – Create Products Programatically [closed]
- Code to auto expire posts after 30 days
- How to use alternate post layout at key points in post loop?
- Changing publish date does not update post order
- WordPress JSON API returns normal site page in html. How do I get it to give me JSON?
- Hide Post comments when displayed via WP_Query
- Show all post titles
- Posts are not showing up on particular category
- Differentiate between posts and pages in search results
- WordPress Theory Lesson – Image Columns within posts with alignment?
- Uppercase first sentence in every post
- Page Navigation for list of post
- Extracting post categories
- How to allow users to post only in certain category and hide elements from edit page?
- Posts and Attachments with “Published” status in Search
- Shortcode to display the latest news article within a page
- How to make the first post in the loop be styled like a “new / featured” post?
- Help diagnosing scheduled post problem with transition_post_status
- Archiving posts in wordpress
- Develop Admin Panel Page
- Can’t give tags rels
- Display password protected posts to logged in users
- How to show content without excerpt?
- Add hero image to home page (blog format) via the dashboard
- All categories displays the same posts
- Having pages after specifying post_type post
- I want to show my post for limited time, how is it possible?
- Display most recent posts in category with Twenty Ten theme widget
- Your ideas on my though “delete or move all of the posts in a specific category when 3 days are passed”
- How Can I Always Display A Particular Post First Using WP_Query?
- How to remove the ManageBlocksMenuItem in the ToolsMoreMenuGroup in the Gutenberg Editor?
- How to preserve HTML from posts in RSS feed
- Run a function when a custom post is update?
- WordPress Post ids big increment
- Add a second rich text input to post editor, and make that content available in post template
- Post images are not displayed in media library
- How can we print out total number of posts filtered by post type and category?
- All my posts don’t show, only the headline is displayed on the homepage
- Daily posts like an archive
- Retrieve latest post by multiple categories with ID
- standard wpGallery for post won’t work
- How remove “recent comments” title without modifying code? [closed]