http://192.168.43.173/api/trades
//簡單的get請求(沒有參數(shù))
@Headers("Cache-Control: no-cache")
@GET("trades")
Call<TradesBean> getItem();
http://192.168.43.173/api/trades/{userId}
//簡單的get請求(URL中帶有參數(shù))
@GET("News/{userId}")
Call<TradesBean> getItem(@Path("userId") String userId);
//簡單的get請求(URL中帶有兩個參數(shù))
@GET("News/{userId}")
Call<TradesBean> getItem(@Path("userId") String userId,@Path("type") String type);
http://192.168.43.173/api/trades?userId={用戶id}
//參數(shù)在url問號之后
@GET("trades")
Call<TradesBean> getItem(@Query("userId") String userId);
http://192.168.43.173/api/trades?userId={用戶id}&type={類型}
@GET("trades")
Call<TradesBean> getItem(@QueryMap Map<String, String> map);
@GET("trades")
Call<TradesBean> getItem(
@Query("userId") String userId,
@QueryMap Map<String, String> map);
POST
http://192.168.43.173/api/trades/{userId}
//需要補全URL,post的數(shù)據(jù)只有一條reason
@FormUrlEncoded
@POST("trades/{userId}")
Call<TradesBean> postResult(
@Path("userId") String userId,
@Field("reason") String reason;
http://192.168.43.173/api/trades/{userId}?token={token}
//需要補全URL,問號后需要加token,post的數(shù)據(jù)只有一條reason
@FormUrlEncoded
@POST("trades/{userId}")
Call<TradesBean> postResult(
@Path("userId") String userId,
@Query("token") String token,
@Field("reason") String reason;
//post一個對象
@POST("trades/{userId}")
Call<TradesBean> postResult(
@Path("userId") String userId,
@Query("token") String token,
@Body TradesBean bean;
//用不同注解post一個實體
@POST("trades/{userId}")
Call<TradesBean> postResult(
@Part("entity") TradesBean bean;
PUT
//put一個實體
@PUT("trade/carInfo/{pid}")
Call<TradesBean> putInfo(
@Path("pid") Int pid,
@Body CarInfoBean carInfoBean;)
DELETE
http://192.168.43.173/api/trades/{userId}
//補全url
@DELETE("trades/{userId}")
Call<TradesBean> deleteInfo(
@Path("userId") String userId;
http://192.168.43.173/api/trades/{userId}?token={token}
//補全url并且后面還token
@DELETE("trades/{userId}")
Call<TradesBean> deleteInfo(
@Path("userId") String userId,
@Query("token") String token;)
@HTTP(method = "DELETE", path = "api/fhs/v1/fhs/{Id}", hasBody = true)
Observable<String> deleteFhs(@Path("Id") String Id);
@Path、@Query凭豪、@Post焙蹭、Body等總結(jié)
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
- 文/潘曉璐 我一進店門刊驴,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人寡润,你說我怎么就攤上這事捆憎。” “怎么了梭纹?”我有些...
- 文/不壞的土叔 我叫張陵躲惰,是天一觀的道長。 經(jīng)常有香客問我变抽,道長础拨,這世上最難降的妖魔是什么? 我笑而不...
- 正文 為了忘掉前任绍载,我火速辦了婚禮诡宗,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘击儡。我一直安慰自己塔沃,他們只是感情好,可當我...
- 文/花漫 我一把揭開白布阳谍。 她就那樣靜靜地躺著蛀柴,像睡著了一般。 火紅的嫁衣襯著肌膚如雪名扛。 梳的紋絲不亂的頭發(fā)上,一...
- 文/蒼蘭香墨 我猛地睜開眼送悔,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了欠啤?” 一聲冷哼從身側(cè)響起,我...
- 正文 年R本政府宣布,位于F島的核電站祭务,受9級特大地震影響内狗,放射性物質(zhì)發(fā)生泄漏柳沙。R本人自食惡果不足惜,卻給世界環(huán)境...
- 文/蒙蒙 一偎行、第九天 我趴在偏房一處隱蔽的房頂上張望蛤袒。 院中可真熱鬧,春花似錦妙真、人聲如沸。這莊子的主人今日做“春日...
- 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至泵琳,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間获列,已是汗流浹背蛔垢。 一陣腳步聲響...
推薦閱讀更多精彩內(nèi)容
- axios中post的body與query傳參區(qū)別及使用總結(jié) Axios發(fā)送請求時params和data的區(qū)別pa...
- 最近開始在項目中使用Retrofit搀庶,在這里總結(jié)一下Retrofit網(wǎng)絡(luò)請求參數(shù)@Path、@Query哥倔、@Que...
- 前端發(fā)送請求最常用的是get請求還有post請求get請求只能傳query參數(shù),query參數(shù)都是拼在請求地址上的...
- 在django1.11的官網(wǎng)中是這么解釋的: HttpRequest.body:The raw HTTP requ...
- 最近在看NestJS缆镣,發(fā)現(xiàn)控制器成員函數(shù)參數(shù)中可以使用@Query、@Body等函數(shù)參數(shù)裝飾器來獲取響應(yīng)的請求數(shù)據(jù)...