0

Ok, I've searched a lot but cannot understand what I'm missing. I need to post some data to a php file on another server, but if I print the wp_remote_post variable I get:

{"headers":{},"body":"","response":{"code":200,"message":"OK"} .....

here the code:

        $url  = 'https://xxx.domain.net/api/api.php';
    $args = array(
            'method'      => 'POST',
            'timeout'     => 45,
            'sslverify'   => false,
            'headers'     => array(
                    'Authorization' => 'xxxx',
                    'Content-Type'  => 'application/json; charset=utf-8',
            ),
            'body'        => json_encode($attachment_fields),
            'data_format' => 'body'
    );
    $request = wp_remote_post( $url, $args );

and $attachment_fields is an array built previously.

It seems that it sends it out (it says code 200) but in the php file the $_REQUEST (or $_POST) is empty... Sorry if is a stupid question but I'm struggling on it for a while..

1 Answer 1

1

Ok, found the problem: I didn't have to json_encode the body.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.