Skip to content
This repository has been archived by the owner on Jul 15, 2021. It is now read-only.

Question: cURL error 3: <url> malformed #95

Closed
thim81 opened this issue Nov 24, 2015 · 2 comments
Closed

Question: cURL error 3: <url> malformed #95

thim81 opened this issue Nov 24, 2015 · 2 comments

Comments

@thim81
Copy link

thim81 commented Nov 24, 2015

Hi,

I started to implementation but I quickly ran into the following strange error

cURL error 3: <url> malformed

Implementation

        $client = $this->get('csa_guzzle.client.api_test');
        $response = $client->request('GET', '/api');

Config

csa_guzzle:
    clients:
        api_test:
            config:
                base_url: "http://localhost:3000"
                defaults:
                    headers:
                        Accept: application/json
            middleware:       []
            class:            GuzzleHttp\Client

If I'm using the full URL, it's working fine

        $client = $this->get('csa_guzzle.client.api_test');
        $response = $client->request('GET', 'http://localhost:3000/api');

Can you point me what I'm doing wrong?
It most be something in my config?

@thim81
Copy link
Author

thim81 commented Nov 24, 2015

Think I have found it.

In your documentation there is a small error

csa_guzzle:
    clients:
        github_api:
            config:
                base_url: https://api.github.com
                defaults:
                    headers:
                        Accept: application/vnd.github.v3+json

Gazzle expects a "base_uri" and the documentation refers to a "base_url"

http://docs.guzzlephp.org/en/latest/quickstart.html?highlight=base_uri

When correcting my example, it works:

csa_guzzle:
    clients:
        api_test:
            config:
                base_uri: "http://localhost:3000"
                defaults:
                    headers:
                        Accept: application/json
            middleware:       []
            class:            GuzzleHttp\Client

@csarrazi
Copy link
Owner

Exactly. I need to update the documentation.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants