As discovered above, headers
need to be (seems so obvious now) key-value pairs, as opposed to an array of json-style key-values:
$headers = array();
$headers['Content-Type'] = 'application/json';
$headers['Api-Key'] = '{myapikey}';
$headers['Siteid'] = '99999';
And the body
needs to be json
so either:
'body' => "{\n \"Username\": \"Siteowner\",\n \"Password\": \"apitest1234\"\n}"
or
'body' => json_encode(array( 'Username' => 'Siteowner', 'Password' => 'apitest1234' ))
Good times, good times.
Related Posts:
- cURL RETURNTRANSFER function in wp_remote_post
- How to convert this cURL to wp_remote_*?
- How to send file by wp_remote_post?
- Does wp_remote_post() require curl?
- wp_remote_post vs curl to send data in WordPress plugin
- Is there a way to follow redirects with command line cURL?
- How to send a header using a HTTP request through a cURL call?
- How can I set the request header for curl?
- How to display request headers with command line curl
- How to fix libeay32.dll was not found error
- cURL to show response headers after submiting a file
- wget/curl large file from google drive
- curl: (35) SSL connect error
- How do I make curl ignore the proxy?
- SSL CA cert (path? access rights?)
- How do I measure request and response times at once using cURL?
- cURL equivalent in Node.js?
- Curl Error 56 “Failure when receiving data from the peer” while sending .tar.gz File
- Run Rsync from Python [duplicate]
- How to use OAuth authentication with REST API via CURL commands?
- cURL 28 error after switch from to brew php 7.2 on localhost
- Creating a post with the REST API, curl and oauth returning 401 error
- HTTP request on localhost failing
- wp_remote_get vs. file_get_contents vs. cURL?
- How can I use CURLOPT_USERPWD in wp_remote_post?
- wp_remote_get – cURL error 28 – only on same domain
- Retrieving Google Plus share count with wp_remote_post
- WordPress API returns empty page when page is less than X-WP-TotalPages
- Login WordPress website using wp-rest api
- cURL – How to send and fetch data in WordPress
- On Plugin Activation, How Do I Check for Proper Transport Mechanism?
- Problem with cURL and rest API
- How to create a post using REST API with sending data as a JSON body?
- How to create custom post by using REST API securely?
- Curl requests sent two times
- Download file using cURL into wp-includes/uploads
- How to code auto-retry for API call
- Uploading a media item with the wp-json API to a specific path
- How to send the body in wp_remote_post as “raw”?
- How to send a HTTP Post request using PHP Curl and WordPress
- REST API works in browser and via AJAX but fails via cURL
- cURL request to plugin repository fails 403
- Curl error while creating user
- Call external API in wordpress based on user input
- Hide response returned from WordPress REST API call
- Set wordpress auth cookie from external site?
- Is it possible to make WordPress as a RESTful app?
- rest_cannot_create_user – Sorry, you are not allowed to create new users. CURL WORDPRESS REST API
- Difference between `curl -I` and `curl -X HEAD`
- upload image with rest API to the media library
- What exactly is cacert.pem for?
- PHP cURL custom headers
- Search WP API using the post title
- How to add category to: ‘wp-admin/post-new.php’?
- Get Image URL instead of Attachment Id in Rest API
- Passing .pem and .key files in cURL doesn’t work in WordPress
- Reduce nonce lifespan
- Add Products to user’s ID Woocommerce
- Cannot edit post meta fields with rest API
- rest_post_query on multiple post types?
- Wp Rest Api Custom Endpoint for page subpages
- Hook before posting via JSON REST API
- Is it posible to use wp.data.select(‘core’) outside a block?
- how to send Ajax request in wordpress backend
- Can you Use the Rest API to query a custom database table
- I am getting error message on accessing menu-endpoint
- How do I get reusable blocks via frontend REST API?
- Custom Rest API POST endpoint with conditionally required parameters
- Is there builtin way to use protected AJAX endpoint?
- WordPress Vue Js Shortcodes
- Custom API endpoint to create gallery for post
- How to get custom fields in a post when published
- Change permissions on REST api?
- How to load content from many posts on a page, only if needed
- Is it Ok to restrict Access-Control-Allow-Origin for /wp-json requests?
- Authenticate current user to REST API
- rest api endpoint – accept diacritic characters
- Tax are not showing on order while placing order with REST API
- Buddypress update user avatar image via REST
- How to execute plugin and theme updates from a web hook / endpoint?
- How to get rest api pagination headers via fetch
- `WP_REST_Controller::get_endpoint_args_for_item_schema` Does Not Set `required` Property from Schema
- wp-json API: not logged in when clicking link to the API from admin mode
- WP Rest API and json_decode()
- Simulating timeout is not working
- Need to use WordPress page as authentication for different service
- wp_nonce vs jwt
- Force REST API Authentication for each request method
- Help to create the best plugin settings!
- How to add taxonomy to a post using WP REST API?
- REST API retrieving posts from www.sitename.com/category/news/ instead of just just from www.sitename.com
- getting posts by tags
- GET request for media files in WP REST API 2 results in an empty array
- Sending WordPress database information to cross domain the safe way?
- WP Rest API feature image breaking react component
- API wp-json/wp/v2/pages/ returns a different result if page is specified
- Headers already sent error with get_template_part in REST API call
- Query posts by custom taxonomy slug in WP REST API?
- oneOf JSON Schema validation not properly working for custom post meta value?
- Uploading media to wordpress API with C# HttpClient