Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot set headers (results in 406 Not Acceptable response) #77

Closed
numediaweb opened this issue Nov 21, 2016 · 3 comments
Closed

Cannot set headers (results in 406 Not Acceptable response) #77

numediaweb opened this issue Nov 21, 2016 · 3 comments
Assignees
Labels

Comments

@numediaweb
Copy link

numediaweb commented Nov 21, 2016

I'm using the bundle inside a service but cannot set the headers using settings:
config.yml:

# EightPoints GuzzleBundle
guzzle:
    clients:
        8p_guzzle_client:
            base_url: '%some_uri_1%'

        my_x_client:
            base_url: '%some_uri_2%'
            headers:
                Accept: 'application/json'

services.yml

services:
    crv.my_connect_api:
        class: AppBundle\My\MyConnect
        arguments:
            - "@guzzle.client.my_x_client"

MyConnect.php

   public function __construct(GuzzleClient $client) {
        $this->client = $client;
    }
   public function login()
    {
        // Call the API
        $response = $this->client->get('/oauth/v2/token');
        dump($client); // client exists and is directing to corret URL
        dump($response); // Client error: `GET http:\/\/some-url.dev\/oauth\/v2\/token` resulted in a `406 Not Acceptable` response:\n\n\n \n \n
        die('It does not work :/');
    }
...

The strange thing is that my IDE (PhpStorm) does not detect the service "@guzzle.client.my_x_client" but detects "@guzzle.client.8p_guzzle_client" inside the services.yml

@leonardocamargo
Copy link

Same here, any solutions?

@florianpreusner
Copy link
Member

Sorry for the late answer 😞
You are right. It seems that all headers in the configuration are not used in any request. I've created a new branch with a hotfix/workaround: #78

It would be great if you can test if this change solves your problem. Afterwards I will clean up the changes and release a new version.

@florianpreusner
Copy link
Member

Released: https://github.com/8p/GuzzleBundle/releases/tag/v5.2.0

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

No branches or pull requests

3 participants