i am trying to send json as raw (html) to wordpress api but its not working for me
$json = json_encode([
'key1' => 'value1',
'key2' => 'value2',
'key3' => 'value3'
]);
$query = http_build_query([
'title' => $titleFile,
'content' => json_decode(stripslashes($json))
]);
$username = 'admin';
$password = '123456';
$url = "http://mysite/wp-json/wp/v2/posts/?$query";
$cmd = "curl --request POST --user $username:$password \"$url\"";
$requestWP = shell_exec($cmd);
print_r($requestWP);
die();
its working fine, but the post is made with json in the body format if I don't decode and if I decode the post is empty as its an array how can I send the value of the key in raw (html) not Json?
wordpress api endpoint https://developer.wordpress.org/rest-api/reference/posts/
output with json_decode()
stdClass Object ( [key1] => value1 [key2] => value2 [key3] => value3 )