“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
- 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 to make an meta_query optional?
- Unrendered content Cornerstone through REST API
- Create a new user using WP REST API and declare meta object
- Ajax call to my WordPress website from an external application [duplicate]
- How Do I Add User Custom Field to REST API Response?
- wordpress custom endpoint multiple params
- register_rest_route regex option for base64 or alternate
- Show different Customizer Settings on Page-Tamplates
- using woocommerce_template_single_add_to_cart in shop-loop – javascript issues [closed]
- how to decode % in app [closed]
- How to generate HMAC-SHA1 signature to use with WP REST API and OAuth1
- Creating login session via CURL
- How do I fetch all comments per post via WP REST API?
- Difference between ‘type’ => ‘text’ and WP_Customize_Control
- Shortcode API: How to get name that matched shortcode RegEx?
- woocommerce registration form with klaviyo(don’t work with current user)
- WordPress 5 WP REST routes – No errors
- Is there an equivalent to WP_Error object I can return in the case of a successful REST request?
- Where Does WordPress Make cURL Requests? How To Add cURL Option
- Change the CSS of the Customizer API
- Create a range slider to change font-size with different screens sizes in wordpress customizer api
- export a csv file from the database with a cronjob
- what is the best practice to add new field to an api route
- How to show single category archive
- wp_remote_get() returns 403 while file_get_contents() does not
- how to save selected option in variable for rest api category filter
- get post content of particular post by url
- Fetching instagram api not working on wordpress
- WordPress from url get external source title
- JSON REST API WordPress only showing first 10 categories
- 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
- Simple WordPress endpoint route doesn’t work
- WordPress REST API register_rest_route give a 500 error
- 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?
- 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
- 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
- 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
- Trouble Accessing Gravity Forms API (GFAPI)
- Call WP Rest-Api to GET /users/me returned NOTHING in console
- WooCommerce REST API AJAX Auth – 401 response
- Looping through and combining calls to Woocommerce REST API
- Need to forward Data from WooCommerce Webhook sent to same site WordPress REST API custom endpoint
- $_GET[‘title’] in WordPress
- 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
- get_body_params() is always empty in POST request
- 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?
- cURL External API request displays content above other content on page
- 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?
- 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
- Trouble Sending Elementor Form Data via cURL in WordPress
- Registered a REST Route but I’m Getting a 400 Bad Request
- Can’t make an external api call in php side of wordpress child theme
- WP_Error Object in wp_remote_post & wp_remote_get
- Custom rest fields not loaded in rest api cpt response