wp_remote_post code conversion

Use this code :

$url="https://xxxx.yyyyy.zzzzz";

$body_array = array(
                        'object_type' => 'Leaderboard',
                        'action' => 'list',
                        'pagination'    => array(
                                                'limit' => 5,
                                                'order' => false
                                            ),
                        'data'          => array(
                                                'username'  => '[email protected]'
                                            )
                    );



$response = wp_remote_post( $url, array(
        'method'      => 'POST',
        'timeout'     => 45,
        'redirection' => 5,
        'httpversion' => '1.0',
        'blocking'    => true,
        'headers'     => array(
                            'x-api-key' => 'ppppppppppppppp',
                            'Content-Type' => 'application/json'
                        ),
        'body'        => json_encode( $body_array ),
        'cookies'     => array()
    )
);

if ( is_wp_error( $response ) ) {
    $error_message = $response->get_error_message();
    echo "Something went wrong: $error_message";
} else {
    echo 'Response:<pre>';
    print_r( $response );
    echo '</pre>';
}