关于Retrofit2 post 提交json字符串,我在这里举个小例子
eg: http://xxxxxx/login?“username”:“xxx”,“password”:"xxxxx"
假设请求url如上所示,{“username”:“xxx”,“password”:“xxxxx”}是请求的数据
我在用retrofit2 写请求时,是这么解决的
@POST(xxx)
Observable<BaseEntity> login(@Body BaseEntity entity);
在这里我建立了一个BaseEntity实体类,然后将请求的数据设置到BaseEntity的对象中,用@Body注解,然后直接传递对象。