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

PUT requests with parameters with location of "postField" result in Exception #78

Closed
tomfotherby opened this issue Mar 11, 2015 · 2 comments

Comments

@tomfotherby
Copy link

I'm using v0.5 of this service. I have a Service Description with a operation that uses 'httpMethod' => 'PUT':

$api = new GuzzleHttp\Command\Guzzle\Description([
            'baseUrl' => $myBaseUrl,
            'operations' => [
                'SubscriberChangeEmail' => [
                    'httpMethod' => 'PUT',
                    'uri' => '/myapp/api/subscriber/changeEmail',
                    'responseModel' => 'changeEmailOutput',
                    'parameters' => [
                        'oldEmail' => [
                            'location' => 'postField',
                        ],
                        'newEmail' => [
                            'location' => 'postField',
                        ],
                    ],
                ],
                ...

When I try to consume the API I get an exception due to my use of 'location' => 'postField':

exception 'RuntimeException' with message 'Must be a POST body interface' in /var/www/apisupertasker/vendor/guzzlehttp/guzzle-services/src/RequestLocation/PostFieldLocation.php:23
Stack trace:
#0 /var/www/apisupertasker/vendor/guzzlehttp/guzzle-services/src/Serializer.php(94): GuzzleHttp\Command\Guzzle\RequestLocation\PostFieldLocation->visit(Object(GuzzleHttp\Command\Command), Object(GuzzleHttp\Message\Request), Object(GuzzleHttp\Command\Guzzle\Parameter), Array)
#1 /var/www/apisupertasker/vendor/guzzlehttp/guzzle-services/src/Serializer.php(57): GuzzleHttp\Command\Guzzle\Serializer->prepareRequest(Object(GuzzleHttp\Command\CommandTransaction), Object(GuzzleHttp\Message\Request))
#2 /var/www/apisupertasker/vendor/guzzlehttp/guzzle-services/src/GuzzleClient.php(101): GuzzleHttp\Command\Guzzle\Serializer->__invoke(Object(GuzzleHttp\Command\CommandTransaction))
#3 /var/www/apisupertasker/vendor/guzzlehttp/command/src/AbstractClient.php(221): GuzzleHttp\Command\Guzzle\GuzzleClient->serializeRequest(Object(GuzzleHttp\Command\CommandTransaction))
#4 /var/www/apisupertasker/vendor/guzzlehttp/command/src/AbstractClient.php(81): GuzzleHttp\Command\AbstractClient->initTransaction(Object(GuzzleHttp\Command\Command))
#5 /var/www/apisupertasker/vendor/guzzlehttp/command/src/AbstractClient.php(76): GuzzleHttp\Command\AbstractClient->execute(Object(GuzzleHttp\Command\Command))

I tried 'location' => 'putField' but that didn't work. I think this was fixed in a previous incarnation of the code, see guzzle/guzzle#278 (but this is in a different git repo - I'm pretty confused about the versions, please excuse me for that 😕 ).

@JLGouwy
Copy link

JLGouwy commented Sep 15, 2015

I have the same problem with Method Patch and location postfield.

I use guzzle 5.0 & service 0.4.*

@Konafets
Copy link
Contributor

I will close this issue. If your problem still exist with latest versions of Guzzle and Guzzle Service, feel free to reopen it.

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

No branches or pull requests

3 participants