Call to undefined method Guzzle\Http\Message\Request::setBody() from /Guzzle/Service/Command/LocationVisitor/Request/JsonVisitor::after()

1,676 views
Skip to first unread message

JakubM

unread,
Nov 26, 2012, 9:23:28 AM11/26/12
to guz...@googlegroups.com
Hi,

I have created client for my API using Guzzle\Service\Client with service description in JSON  but when I try to call anything I get this php error:

PHP Fatal error:  Call to undefined method Guzzle\Http\Message\Request::setBody() in /.../vendor/guzzle/guzzle/src/Guzzle/Service/Command/LocationVisitor/Request/JsonVisitor.php on line 67

which concerns this row of code: $request->setBody(json_encode($json)); 

I found out class of $request object and it is this: Guzzle\Http\Message\Request but it does not have setBody() method defined. Am I doing something wrong or there is a bug? 

Thanks a lot for any help.

Regards,
Jakub

Michael

unread,
Nov 26, 2012, 4:50:42 PM11/26/12
to guz...@googlegroups.com
Hi Jakub,

You need to make sure that your description is using a POST, PUT, or DELETE request when you are using json parameter locations. If you do not specify an httpMethod attribute, then the description assumes a GET request. GET requests do not have a `setBody()` method.

-Michael

JakubM

unread,
Nov 28, 2012, 4:02:50 AM11/28/12
to guz...@googlegroups.com
Hi Michael,

of course it was this silly mistake, I was just puzzled by the error message I got.

Thanks a lot!

Jakub
Reply all
Reply to author
Forward
0 new messages