Yii Framework Forum: Curl malformed URL - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Curl malformed URL

#1 User is offline   Jonny 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 240
  • Joined: 26-December 11

Posted 03 May 2017 - 02:28 PM

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/...url-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?
0

#2 User is offline   Jonny 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 240
  • Joined: 26-December 11

Posted 04 May 2017 - 07:48 AM

View PostJonny, on 03 May 2017 - 02:28 PM, said:

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/...url-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?


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"
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users