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
- Send post to remote wp site from post edit window with all data excerpt image
- Server 500 error when updating post using block editor
- WordPress REST API – Create post not working with 401 response but list posts working
- REST API – Retrieving posts with custom status
- WordPress Rest API Post request from AMP
- Cannot create posts via REST API
- Yoast breadcrumb URL shows category instead of the page
- Post Image Gallery After Content Function messes with other content
- Embedding Post Editor Into External Site
- Add data attribute of post_id for Internal links
- Single Post Gallery Using Shortcode
- Please help a newbie with blog page issue?
- How to insert custom text after H1 to all my blog posts?
- Posting an article containing mathematical symbols and R code
- How to create loop of posts except post ID defined via ACF field
- Menu Items disappearing/being empty on save or post edit
- Alt text attributes not showing over portfolio images
- Show single post child category from a determined parent
- Author post count in category
- How to work with posts and sub posts?
- wordpress admin missing Posts button
- How to show posts in grid style on search result page?
- My website is showing today’s date instead of published date since db migration to a new wordpress
- How can I change the date format of the revision list?
- Single Post function to display all single post images in a carousel
- Set post title font size automatically according to number of words in post title
- Get post slug and match with menu item slug to change css
- Run a function when a custom post is update?
- WordPress Post ids big increment
- Every time I try accessing a post it redirects me to the feed
- How can I create a ‘sub-blog’ which has its own sidebar on individual posts?
- MYSQL: Create SQL query to search for string and replace
- How to remove special characters in post title
- My page shows some other content in WP
- Query to fetch custom taxonomy along with post title
- Related post not showing table of content
- Search results with pagination not working
- Get html from custom route api
- My post permalinks are redirecting to the post archive page for some reason?
- How to disable WordPress from automatically changing “x” to multiplication symbol “×” when typing numbers that also contain an “x” between them?
- Not adding a new post?
- Add class to global $post
- Prevent the automatic URL linking added in last update
- how to create JSON array [] for REST response?