Koper
Koper

Reputation: 123

Symfony2 Guzzle set HTTP request

I am working in Symfony2 and I try to use Guzzle in one of my tests(PHPUnit) to set some values into my request.

I want to add these into my request:

 $string = '{
            "postcode":"XXX-XXX",
            "source_channel":"BU",
            "flow":"ENQUIRY",
            "email_address":"test@test",
            "first_name":"Bob",
            "surname":"White",
            "User-Agent":"Mozilla",
        }';

My guzzle code:

$client = new \Guzzle\Http\Client();
$post = $client->post('http://127.0.0.1/api/save/details', array(), $string);
$data = $post->send();

Error:

Guzzle\Http\Exception\ClientErrorResponseException: Client error response
[status code] 404
[reason phrase] Not Found
[url] http://127.0.0.1/api/save/details

I am really new to guzzle but it seems straight forward in what I am trying to do. I assume from the error message might be wrong but something is wrong with URL which for a fact I know is good....

Any idea what might be going wrong here?

Upvotes: 1

Views: 741

Answers (1)

mika
mika

Reputation: 1971

It looks to me that there is a typo in the domain part of your url. Try to change

'http://127.0.0.1:/api/save/details'

to

'http://127.0.0.1/api/save/details'

Upvotes: 2

Related Questions