Retrofit no key name on URL parameter

2019-08-04 13:33发布

问题:

I need to call an Api on retrofit just like that sample:

http://api.paco.com/c?version_int&somekey&someotherkey&lastkey&user+input&some_base64

I dont need the key parameter specification, just the value straight implicit (ie: &somekey=value&someotherkey=value)

I'd concatenate on a @Path, but I have some doubts about the elegance.

回答1:

Try this way.

You can pass entire query to your rest api method like this:

callMethod("?version_int&somekey&someotherkey&lastkey&user+input&some_base64")

In REST api method use it like this:

@GET("/c{query}")
void callMethod(@EncodedPath("query") String query);

I hope it helps!