“The REST API uses JSON exclusively as the request and response format, including error responses.”
I would try explicitly setting the content type/length and json encode your data with something like this (assuming you need to specify all the options you did in your code provided):
$data = array(
'title' => 'testTitle',
'content' => '',
);
$data = json_encode( $data );
$header = array(
buildAuthorizationHeader( $oauth ),
'Content-Type: application/json',
'Content-Length: ' . strlen( $data ),
'Expect:',
);
$options = array(
CURLOPT_HTTPHEADER => $header,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_POST => true,
CURLOPT_URL => $url,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_POSTFIELDS => $data,
);
Related Posts:
- cURL 28 error after switch from to brew php 7.2 on localhost
- Does the REST API (official) support custom post types?
- Woocommerce api: create product with images – bad request
- Building a REST API for your web app exposes primary keys of DB records?
- How to set a template with wp_insert_post
- Is it possible to create new user from external form using REST API?
- REST API works in browser and via AJAX but fails via cURL
- How to clone all WordPress Rest API end points
- How do i post data to url with fields?
- rest_cannot_create_user – Sorry, you are not allowed to create new users. CURL WORDPRESS REST API
- Adding Microsoft Teams Incoming Webhook to WordPress, Problem with Rest Route?
- What is different about using admin-ajax.php in an endpoint and just submitting a form from the front end?
- REST API Plugin Update call back not updating the plugin
- register_rest_route, Compare purchase codes and send a response
- Can external API content be added to Rest API in WordPress
- Authorization and execution of the link
- What’s the net::ERR_HTTP2_PROTOCOL_ERROR about?
- Uploading media with the REST API
- WP-API v2 Custom Endpoint Response Formatting
- How to loop through JSON data in wordpress WP REST API
- How can I call specific function if requested URL is not found?
- JSON REST API WordPress only showing first 10 categories
- Buddypress update user avatar image via REST
- Delete taxonomy and delete all post related it
- Permission callback to check if user has application password
- Multiple requests external data api dynamic block gutenberg
- How can I spin up a new website for a registered user automatically?
- Simple WordPress endpoint route doesn’t work
- Cant register rest routs from class instance
- WordPress REST API register_rest_route give a 500 error
- WordPress transient not working with WP Engine
- WC_Customer delete function returns error
- How to send a HTTP Post request using PHP Curl and WordPress
- Custom route and query
- Validate and Sanitize WP REST API Request using WP JSON Schema?
- SOAP Request/Parsing XML From wp_send_json_success
- Filter by field with array value in ACF on WP REST API
- cURL error 6 on news area, and also won’t auto update
- Post to WordPress from another Server via PHP
- Accessing an API with jQuery and AJAX
- calling admin-ajax.php from admin-ajax.php
- Export post data with xml to other site using php soap
- no_rest_route error on custom routes
- Flatten Responses returned via WP REST API via WP_Error for obfuscation
- WP_REST_Response – How to return Gzip answer and add Content-encoding header?
- Generate images with html2canvas and the woocommerce api
- Creating a brand attribute as a variable
- WordPress api post image raw data without being blank in media library
- REST api returns 404 on some WordPress sites
- Integrate admin plugin into template. Very interesant (live search + autocomplete with wp rest api, in vanilla js)
- Require()/Include() post template adding extra content
- Create a WordPress Contact Form to call a POST AWS API Gateway and send user data
- WordPress 5.6 Application Passwords
- Force REST API Authentication for each request method
- Trouble Accessing Gravity Forms API (GFAPI)
- Call WP Rest-Api to GET /users/me returned NOTHING in console
- REST API custom endpoint to fetch pages and posts not working
- WooCommerce REST API AJAX Auth – 401 response
- Looping through and combining calls to Woocommerce REST API
- get Woocommerce product format json for WP_Query
- Need to forward Data from WooCommerce Webhook sent to same site WordPress REST API custom endpoint
- $_GET[‘title’] in WordPress
- How do I create a WP endpoint that retrieves all custom post types that have a tag?
- Pulling Products from an API
- Contactform7: display results from CURL
- Require advice handling a URL redirect from a Third Party. URL Params need to populate and then forward to payment
- How can i get the same ajax result using WP REST API instead of admin-ajax?
- WP HTTP API call response
- AdWords API with WP
- Run A Pre-Built Core PHP Application Under A WordPress Page or Post Route
- base64_encode conflict with convert_smilies in wordpress
- get_body_params() is always empty in POST request
- Headers already sent error with get_template_part in REST API call
- Properly process a custom WP REST API request (Authenticate, Authorize + Validate)?
- How to pass and validate nonce in custom REST routes
- Query posts by custom taxonomy slug in WP REST API?
- oneOf JSON Schema validation not properly working for custom post meta value?
- cURL External API request displays content above other content on page
- Create custom API endpoint to change custom header image
- Why is this specific API request failing when sending via wp_remote_post?
- How to cut a section of a URL from a string with a regular expression?
- REST API custom endpoints for metaboxes
- Authenticate + Authorize WP REST API request before built-in WP JSON Schema Payload Validation?
- WordPress REST API – Custom field not added to pages
- cURL running slow in WordPress
- wordpress-plugin (widget) that performs a Neaby-search on the openstreetmap-endpoint: around x find y
- regsiter a new user through WordPress API with Google SSO doesn’t work properly
- Display endpoint’s return into a file (file_put_contents())
- Read data from external source. XML vs REST API
- Encountering 400 Bad Request Error When Sending Form Information to API through Elementor
- Trouble Sending Elementor Form Data via cURL in WordPress
- Application password header not checked in REST API
- Registered a REST Route but I’m Getting a 400 Bad Request
- How to pass a file to an API call through WordPress
- Can’t make an external api call in php side of wordpress child theme
- WP_Error Object in wp_remote_post & wp_remote_get
- WordPress Custom API GET request from External App with XML Parameter
- WP rest api and litespeed incompatibility
- Custom rest fields not loaded in rest api cpt response
- REST API request between domain and subdomain