We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

ask : using '&' or '?' on annotation controller

good morning all...i have trouble with url using api...i have url like this

"https://localhost/phalcon-api/public/api/products/id=911'"

i want add string like "?" or "&" and then thats url will be like :

"https://localhost/phalcon-api/public/api/products?id=911&token=token'"

but, when i run on postman...that's repons like :

"{ "status": "011002", "message": "API NOT FOUND." }"

oh yes, i forgot..this is my annotation

*   get detail products by products_id
*   URL : https://localhost/phalcon-api/public/api/products/?id=616031221770
*   @return detail products_id
*   @Route(method = "get", route = "?id={master_products_id}!token=token", authentication = false)

how i can use this string "?" on my url..thanks after ^_^

Instead of ? use %3F and %26 for &

thanks for your answers...but when i use

*   get detail products by products_id
*   URL : https://localhost/phalcon-api/public/api/products/?id=616031221770
*   @return detail products_id
*   @Route(method = "get", route = "id={master_products_id}{%26}token={token}", authentication = false)

that's string for "&" and "?", still view error "message": "API NOT FOUND."...any one have solution again? thanks

edited Mar '16

Wait a minute. What you want to achievie ? I thought you wanted to pass & or ? in url ?

https://localhost/phalcon-api/public/api/products/?id=616031221770

I dont see %26 in url ?

yes bro, sorry i'm wrong put "?" to route..i mean like this

*   get detail products by products_id
*   URL : https://localhost/phalcon-api/public/api/products/?id=616031221770
*   @return detail products_id
*   @Route(method = "get", route = "{%26}id={master_products_id}!token={token}", authentication = false)

but, still not found too...whats wrong with my route.thanks

edited Mar '16

You can't define query parameters in route, this:

?id=616031221770

Is query parameter.

You can access it in action like this:

    $this->request->getQuery('id)

So your route should be /api/products/ or /products/ depending on your base path and you can do all checks for query parameters in action. Sorry for that, currently no option to define query parameters in route definition.

That's nice. I think it should be built-in in phalcon

Check out https://github.com/sidroberts/phalcon-requiredparams