简体   繁体   中英

How to add post query parameter string with double quote in url in retrofit?

I am accessing an api .which looks like

http://XXX.XX.XXX.XXX/api/Gallery/getgallerylist?userid="17" .

I have tried the following annotation.

 @POST("Gallery/getgallerylist")
    Call<GalleryImagesResponse> getGalleryImages(@Query("userid") String userid);

But the url it requests is http://XXX.XX.XXX.XXX/api/Gallery/getgallerylist?userid=17

So that how can I add double quote to userid's value like userid="17".

You can pass the string as @Path to the URL like this.

@POST("http://XXX.XX.XXX.XXX/api/Gallery/getgallerylist?" + "{path}")
Call<ResponseBody> getGalleryImages(@Path("path") String path);

and pass userid=17 to this call, it will append to the URL. and your done

您应该在点击url之前尝试一下

URLDecoder.decode(url,UTF8);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM