I'm trying to work with an API that expects an XML string in the body of the post. Additionally, the docs for the API specify:
Please post with mime-type text/xml with the XML in the body of the post
I want to use the WordPress HTTP API to make this work, but I'm running into some problems. So far I have code like the following that seems to be failing.
$url = 'https://www.testurl.com'; $xml = <<<TESTED XML HERE>>>; $response = wp_remote_post( $url, array( 'method' => 'POST', 'timeout' => 45, 'redirection' => 5, 'httpversion' => '1.0', 'headers' => array( 'mime-type' => 'text/xml' ), 'body' => array('xml' => $xml), 'sslverify' => false ) );
My question is, am I properly setting the mime-type and am I sending the XML in the right place?
It's surprisingly tough to find examples of the WordPress HTTP API utilizing XML requests.