Sorry Tim, I’ve been away the past few days. It looks like the discourse_request
method needs tweaking to support this. I’ll make a PR for that next week and it’ll probably take another week for that to be merged.
If you want it sooner than that you can use the underlying WP methods like so:
$api_credentials = DiscourseUtilities::get_api_credentials();
if ( is_wp_error( $api_credentials ) ) {
return $api_credentials;
}
$headers = array(
'Api-Key' => sanitize_key( $api_credentials['api_key'] ),
'Api-Username' => sanitize_text_field( $api_credentials['api_username'] ),
'Accept' => 'application/json',
);
$body = array( /* specific to the endpoint you're using */ );
$url = /* The absolute url for the endpoint you're using */;
$opts = array(
'headers' => $headers,
'body' => json_encode( $body ),
'method' => 'PUT'
);
$result = wp_remote_request( $url, $opts );