0

http://example.com/api/transfer/transfers/code/456/code/234

When using $this->get('code') on a url like above I expect the REST library to return an array or a list of the codes.

Instead it returns the last one.

Is there a way to return both values in a list, or is there another recommandation for formating the URL.

Thank you

orbitory
  • 1,090
  • 5
  • 16
  • 40

1 Answers1

0

I know it has been long since you posted the question. However it could help other people looking for the same thing.

Assuming that transfer is your controller and transfers is the function, another way to format your url could be:

http://example.com/api/transfer/transfers?code[]=456&code[]=234

This was you perform $this->get('code') you'll get an array back.

If you are creating the url via code then you may use http_build_query(). It handles the necessary escaping. It means it will replace [ for %5B and ] for %5D, in this case.

The code would be like:

$codes = array(456, 234); 
$query = http_build_query(array('code' => $data));
$url = 'http://example.com/api/transfer/transfers?' . $query;
Hicaro
  • 687
  • 2
  • 8
  • 21