Curl malformed URL


(Jono Wozere) #1

I am trying to test the REST API module in my Yii2 system and having some trouble with a simple Get Request. I’ve done a lot of variations of this call, but always get back:

[GuzzleHttp\Exception\RequestException] cURL error 3: <url> malformed (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)

This is my code:


public function userIsAuthenticated(\ApiTester $I)

    {

        $I->amGoingTo('Attempt to see if Im authenticated');

        $I->amHttpAuthenticated('my_access_token', '');

        $I->sendGET(Url::toRoute('/api/orders'), ['id' => 4]);

        $I->seeResponseCodeIs(\Codeception\Util\HttpCode::OK); // 200

    }

If I echo out the Url::toRoute and put it’s output into the web browser, it asks me for my auth token. So I’m fairly confident the path is good.

What have I done wrong?


(Jono Wozere) #2

Fixed this by changing my yml config for the url, to the full url "http://localhost/api" rather than what I had previously which was "/api"