2

I'm unable to use put http requests in WordPress.

https://codex.wordpress.org/HTTP_API

This link says you can do it through wp_remote_request()? But where to specify that ?

Can anyone help me with this? I need a code.

2 Answers 2

11
$body = array(
            "status" => "publish"
);
$args = array(
    'headers' => array(
    'Content-Type'   => 'application/json',
    ),
    'body'      => json_encode($body),
    'method'    => 'PUT'
);

$result =  wp_remote_request( "http:300/wp-json/wp/post/1", $args );
Sign up to request clarification or add additional context in comments.

Comments

4

Like this

$response = wp_remote_request( 'http://test.com/test', [
    'method' => 'PUT'
] );

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.