Problem

I have an operation with one optional parameter without default value. It is real use case: see 'cursor' parameter in "List Accounts" request definition at http://docs.recurly.com/api/accounts.
This makes request URI look like
https://:subdomain.recurly.com/v2/accounts?state=active&per_page=50&cursor=.
It breaks the entire request - so the Recurly service returns response 200 with no content inside.

Solution

We should check remaining parameters whether they are not empty - and only then include them into request URI.

Comments

PatchRanger’s picture

Status: Active » Needs review
StatusFileSize
new902 bytes

Done, please review.

tito.brasolin’s picture

Hello PatchRanger. A few months ago I had exactly your same problem, so I posted this feature request (with patch): https://drupal.org/node/1934274

Your patch looks fine (imho), but what if an empty parameter does have some meaning for the server? #1934274 can solve your problem in a more generalized and flexible way, just copy and paste the example (wsclient_rest.api.php) into your custom module or in https://drupal.org/project/myhook

function hook_wsclient_rest_request_alter(&$request, &$service) {
  if ($service->name == 'myservice') {
    // remove empty parameters
    $request->parameters = array_filter($request->parameters, 'strlen');
  }
PatchRanger’s picture

Status: Needs review » Closed (duplicate)

Thanks a lot, I agree that your solution is more flexible.
I did look for related issues - but failed to find yours.
Closing this issue as duplicate of #1934274: Add support for $request_alter.