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

1 Answer 1

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;
Sign up to request clarification or add additional context in comments.

1 Comment

In this case you might as well use code/456||234 and always do an explode on || (not tested). Thx

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.