Retrofit get post query filed FiledMap
来源:互联网 发布:b超数据看胎儿性别 编辑:程序博客网 时间:2024/06/05 17:09
直接请求型
1.如果是直接请求某一地址,写法如下:
@GET(“/record”)
Call getResult();
2.如果是组合后直接请求,如/result/{id}写法如下:
@GET(“/result/{id}”)
Call getResult(@Path(“id”) String id);
带参查询型
如12306的查询接口https://kyfw.12306.cn/otn/lcxxcx/query?purpose_codes=ADULT&queryDate=2016-03-18&from_station=BJP&to_station=CDW,写法如下:
@GET(“/otn/lcxxcx/query”)
Call query(@Query(“purpose_codes”) String codes, @Query(“queryDate”) String date,
@Query(“from_station”) String from, @Query(“to_station”) String to)
带Header型
比如要更新某个账户信息,其接口地址为/info,需要带的Header有设备信息device,系统版本version,还要带请求参数要更新账户的id,代码如下:
@POST(“/info”)
Call updateInfo(@Header(“device”) String device, @Header(“version”) int version,
@Field(“id”) String id);
HTTP请求方式:POST
请求示例为:
Request URL:http://api.duoshuo.com/posts/create.json
Request Method:POST
Post Data:short_name=official&author_email=jp.chenyang%40gmail.com&author_name=Perchouli&thread_id=1152923703638301959&author_url=http%3A%2F%2Fduoshuo.com&message=匿名发表新评论
1.Field方式实现
@FormUrlEncoded
@POST(“/posts/create.json”)
Call createCommit(@Field(“secret”) String secret,
@Field(“short_name”) String shortName,
@Field(“author_email”) String authorEmail,
@Field(“author_name”) String authorName,
@Field(“thread_key”) String threadKey,
@Field(“author_url”) String author_url,
@Field(“message”) String message);
2.Field Map实现方式
@FormUrlEncoded
@POST(“/posts/create.json”)
Call createCommit(@FieldMap Map
- Retrofit get post query filed FiledMap
- Retrofit一GET,POST
- 利用Retrofit执行Post、Get请求,通俗易懂
- Retrofit的Get与Post请求
- Retrofit的基本post,get请求
- Retrofit基础之:GET与POST请求
- Retrofit get、post请求用法整理
- Okhttp和Retrofit的get,post请求
- retrofit的 get post 请求 + log日志
- 利用Retrofit执行Post、Get请求,通俗易懂
- 记录Retrofit的post,get用法。
- Query Ajax 实例 ($.ajax、$.post、$.get)
- Query Ajax 实例 ($.ajax、$.post、$.get)
- Java反射 Filed.get(null)
- Retrofit的(get以及post)的简单使用
- Retrofit 使用心得 @GET@POST带参数不带参数
- RxAndroid组合Retrofit 实现文件上传 post get
- 两行代码搞定发送 Retrofit GET/POST 请求
- 输入的时候较应 字母和数字
- 安卓Html5编程(一)
- 第十三周项目1.4—分数类中的运算符重载
- Android App数据格式Json解析方法和常见问题
- java里面如何截取两个关键字中间的字符串
- Retrofit get post query filed FiledMap
- Masonry的基本使用方法
- oracle imp (表导不出)
- xgboost: 速度快效果好的boosting模型
- Android官方MVP架构解读
- 接受一个整数n,如果是正数,列出1~n之间所有的数,如果是负数,用break或return退出,为0的话转到1,继续接受下一个数
- UIGestureRecognizer学习之—— UIRotationGestureRecognizer
- 救硬盘 分区变成RAW格式 恢复 救回
- c# 根据当前时间获取,本周,本月,本季度,月初,月末,各个时间段