retrofit
retrofit copied to clipboard
Add support for "-G" curl option
In Stripe APIs the filtering can be done by sending parameters with "-G" curl option, as example https://stripe.com/docs/api/accounts/list#list_accounts-created
curl https://api.stripe.com/v1/accounts?limit=3 \
-u sk_test_BQokikJOvBiI2HlWgH4olfQ2: \
-d created[lte]=1517443200 \
-G
When used, this option will make all data specified with -d, --data, --data-binary or --data-urlencode to be used in an HTTP GET request instead of the POST request that otherwise would be used. The data will be appended to the URL with a '?' separator. From https://curl.haxx.se/docs/manpage.html
What is the final URL of that example and how is it different than regular query parameters?
On Sat, Aug 3, 2019, 2:01 AM Alex [email protected] wrote:
In Stripe APIs the filtering can be done by sending parameters with "-G" curl option, as example https://stripe.com/docs/api/accounts/list#list_accounts-created
curl https://api.stripe.com/v1/accounts?limit=3
-u sk_test_4eC39HqLyjWDarjtT1zdp7dc: \
- d "created[lt]=1385798567"
-GWhen used, this option will make all data specified with -d, --data, --data-binary or --data-urlencode to be used in an HTTP GET request instead of the POST request that otherwise would be used. The data will be appended to the URL with a '?' separator. From https://curl.haxx.se/docs/manpage.html
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/square/retrofit/issues/3187?email_source=notifications&email_token=AAAQIEN7EVPDFOVRIPRGOIDQCUNKPA5CNFSM4IJCKF22YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HDFS5RA, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAQIEOAOAJYKPGRH5L3EZTQCUNKPANCNFSM4IJCKF2Q .
I've imported the curl request into Postman and it generates
GET https://api.stripe.com/v1/accounts?limit=3?created[lte]=1517443200
https://github.com/postmanlabs/curl-to-postman/issues/4
I don't really understand how this is useful over @Query-annotated parameters. Can you please provide an example of what you are trying to achieve that is impossible with @Query and @QueryMap?
Has been almost a year now, but for someone looking for the same than @raderio, maybe this will help. With the Jake's comment, I just looked for annotation @Query, and as an example:
@GET("Route") Observable<RoutesResponse> getRoutes(@Query("where") String query, @HeaderMap Map<String, String> headers);
I had a POJO for that query but It doesn't work with @Query as it gives me a 500 Internal Server Error, and I just, convert it to a String with gson:
restClient.getRoutes(getGson().toJson(request), headers); // getGson() is in the RequestModel