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
- register_rest_route, Compare purchase codes and send a response
- 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
- Send post to remote wp site from post edit window with all data excerpt image
- What is different about using admin-ajax.php in an endpoint and just submitting a form from the front end?
- After upgrading WordPress, I am getting the following error. Error message: cURL error 52: Empty reply from server
- 504 Gateway Time-out error when making cURL request in WordPress
- Authorization and execution of the link
- WP_Error Object in wp_remote_post & wp_remote_get
- How do I get a YouTube video thumbnail from the YouTube API?
- How do I POST JSON data with cURL?
- What’s the net::ERR_HTTP2_PROTOCOL_ERROR about?
- JSONDecodeError: Expecting value: line 1 column 1 (char 0)
- curl: (60) SSL certificate problem: unable to get local issuer certificate
- HTTP POST and GET using cURL in Linux [duplicate]
- How do I POST JSON data with cURL?
- curl: (60) SSL certificate problem: unable to get local issuer certificate
- JSONDecodeError: Expecting value: line 1 column 1 (char 0)
- How do I install and use cURL on Windows?
- JSONDecodeError: Expecting value: line 1 column 1 (char 0)
- How to fix “SSL certificate problem: self signed certificate in certificate chain” error?
- How to use Python to execute a cURL command?
- What’s the net::ERR_HTTP2_PROTOCOL_ERROR about?
- How to use Python to execute a cURL command?
- How to define the basic HTTP authentication using cURL correctly?
- How to use the curl command in PowerShell?
- https connection using CURL from command line
- performing HTTP requests with cURL (using PROXY)
- How to define the basic HTTP authentication using cURL correctly?
- Curl command for https ( SSL )
- How to do a PUT request with cURL?
- How to capture cURL output to a file?
- Using cURL with a username and password?
- PHP + curl, HTTP POST sample code?
- What is the curl error 52 “empty reply from server”?
- Can curl make a connection to any TCP ports, not just HTTP/HTTPS?
- curl: (6) Could not resolve host: google.com; Name or service not known
- Call to undefined function curl_init().?
- How do I get a YouTube video thumbnail from the YouTube API?
- How to use cURL to send Cookies?
- How do I POST JSON data with cURL?
- CURL ERROR: Recv failure: Connection reset by peer – PHP Curl
- cURL error 60: SSL certificate: unable to get local issuer certificate
- Binary Data Posting with curl
- What exactly is cacert.pem for?
- curl POST format for CURLOPT_POSTFIELDS
- tar: Unrecognized archive format error when trying to unpack flower_photos.tgz, TF tutorials on OSX
- curl : (1) Protocol https not supported or disabled in libcurl
- HTTP Error 411, The request must be chunked or have a content length
- Curl not recognized as an internal or external command, operable program or batch file
- PHP cURL custom headers
- PHP cURL HTTP PUT