Retrofit get post query filed FiledMap
直接请求型
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使用指南
Retrofit is a type-safe HTTP client for Android and Java. Retrofit是面向Android和Java平台的一个类型安全的HTTP客户端. ...
- 六、Solr高亮与Field权重
Solr高亮 原理 做搜索时,高亮是很常见的需求,那么Solr肯定也为高亮提供了支持.先解释下Solr高亮的原理,在我们设置了需要高亮显示的Field之后,查询得到的返回结果会多出来下面的内容: &q ...
- Solr高亮与Field权重
Solr高亮与Field权重 Solr高亮 原理 做搜索时,高亮是很常见的需求,那么Solr肯定也为高亮提供了支持.先解释下Solr高亮的原理,在我们设置了需要高亮显示的Field之后,查询得到的 ...
- java课程设计团队博客《基于学院的搜索引擎》
JAVA课程设计 基于学院网站的搜索引擎 对学院网站用爬虫进行抓取.建索(需要中文分词).排序(可选).搜索.数据摘要高亮.分页显示.Web界面. 一.团队介绍 学号 班级 姓名 简介 2016211 ...
- 【Android】Retrofit网络请求Service,@Path、@Query、@QueryMap...
对Retrofit已经使用了一点时间了,是时候归纳一下各种网络请求的service了. 下面分为GET.POST.DELETE还有PUT的请求,说明@Path.@Query.@QueryMap.@Bo ...
- Android】Retrofit网络请求参数注解,@Path、@Query、@QueryMap...(转)
对Retrofit已经使用了一点时间了,是时候归纳一下各种网络请求的service了. 下面分为GET.POST.DELETE还有PUT的请求,说明@Path.@Query.@QueryMap.@Bo ...
- 【Android】Retrofit网络请求参数注解,@Path、@Query、@QueryMap.
对Retrofit已经使用了一点时间了,是时候归纳一下各种网络请求的service了. 下面分为GET.POST.DELETE还有PUT的请求,说明@Path.@Query.@QueryMap.@Bo ...
- Android Retrofit网络请求Service,@Path、@Query、@QueryMap、@FieldMap (转)
GET请求 多个参数在URL问号之后,且个数不确定 http://api.stay4it.com/News?newsId=1&type=类型1- http://api.stay4it.com/ ...
- android retrofit @Query用法
http://www.b3a4a.com/?id=71 //https://login.xx.cn/mobile/login?access_token=A7E3D8CC98776F7C16F328B6 ...
随机推荐
- java:图片压缩
java使用google开源工具实现图片压缩 :http://www.cnblogs.com/linkstar/p/7412012.html
- 小程序里打开app的实现过程
之前开发过类似得需求,也踩了一些小坑,在这里和大家分享下,毕竟这样的需求也不在少数,基本上产品后期都会有这样的需求: 官方说明 因为需要用户主动触发才能打开 APP,所以该功能不由 API 来调用,需 ...
- PHP使用MySQL报no such file or directory
原因是没有连接数据库.加上下面代码: $link = mysql_connect(DB_HOST,DB_USER,DB_PWD);mysql_select_db(DB_NAME) or die('Co ...
- 笨办法学Python(十二)
习题 12:提示别人 当你键入 raw_input() 的时候,你需要键入 ( 和 ) 也就是“括号(parenthesis)”.这和你格式化输出两个以上变量时的情况有点类似,比如说 "%s ...
- 关于vim、nvim的折腾
1 from a view of enc ·nvim必须set enc=utf8,很多基于python的插件也默认了此,这对于中文这些并不友好,然而,vim支持多字节就好的多. 因为很多项目,大家可能 ...
- veritas.com常用资源汇总
NetBackup 8.1.2文档(合集) https://www.veritas.com/support/en_US/article.100044086 NetBackup产品组停止支持生命周期 ...
- python对表格的使用
#!user/bin/env python # coding=utf- import xlrd def readExcelDataByName(filename, sheetName): '''读取E ...
- 2017.10.14 Java的流程控制语句switch&&随机点名器
今日内容介绍 1.流程控制语句switch 2.数组 3.随机点名器案例 ###01switch语句解构 * A:switch语句解构 * a:switch只能针对某个表达式的值作 ...
- caffe RandomBrightness和RandomContrast
1. void RandomBrightness(const cv::Mat& in_img, cv::Mat* out_img, const float brightness_prob, c ...
- leetcode_No.1 Two Sum
原题: Given an array of integers, return indices of the two numbers such that they add up to a specifi ...