0

I am trying to make a GET request to a url from my wordpress installation to get the access token but I receive this error:

WP_Error Object ( [errors] => Array ( [http_request_failed] => Array ( [0] => cURL error 7: couldn't connect to host ) ) [error_data] => Array ( ) )

If I make a get request to another url it works, if I make the same request from postman then it works again. If I paste the url in the browser I get {"error":"unsupported_grant_type"}. Only from the wordpress Installation it doesn't work. I have tried with build in functions of wordpress and cURL but I always get the same cURL error 7: couldn't connect to host...

Here is the code (similar with cUrl - same headers same body):

$response = wp_remote_request( 'https://subd.dom.mobi:5656/SyncServerAPI/token',
        [
            'headers'     => ['Content-type' => 'application/x-www-form-urlencoded'],
            'body' => [
                            'method' => 'GET',
                            'grant-type' => 'password',
                            'username' => 'usrnm',
                            'password' => 'pswrd',
                        ]
        ]
    );

    print_r($response);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.