Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# 1. Install this plugin in wordpress:
# https://github.com/WP-API/Basic-Auth
# 2. Create wordpress user with username 'admin' and password 'admin'
# 3. Download an image and save it as 'google.jpg'
# 4. Upload image to wordpress REST API
curl \
-H "cache-control: no-cache" \
-H "Content-Type: image/jpg" \
-H 'Content-Disposition: attachment; filename=google.jpg' \
--data-binary "@$PWD/google.jpg" \
--user admin:admin http://127.0.0.1/wp-json/wp/v2/media
# 5. Create post with previously uploaded image as featured media
curl \
-H "Content-Type: application/json" \
-d '{"title":"My New Title", "content": "My content", "excerpt": "My excerpt", "status": "publish", "featured_media": 1}' \
--user admin:admin \
http://127.0.0.1/wp-json/wp/v2/posts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.