liyyanli

导航

 


问题1:java.lang.IllegalStateException: Expected a string but was BEGIN_OBJECT at line 1 column 2 path $

@FormUrlEncoded
@POST("userLogin")
Observable<Object> userLogin(@Field
mPostLocation.userLogin(sfflag,telephone,
        password,phoneid,phonemodel,versions)
        .subscribeOn(Schedulers.newThread())
        .observeOn(AndroidSchedulers.mainThread())
        .subscribe(new BaseObserver<Object>(cnt) {

@PartMap parameters can only be used with multipart encoding. (parameter #2)

java.lang.IllegalArgumentException: Only one encoding annotation is allowed.
@Field parameters can only be used with form encoding.

@PartMap 需要使用注解/*@Multipart*/ 
@Field需要使用到注解:@FormUrlEncoded

两个不能同时使用,否则会报 Only one encoding annotation is allowed.

使用@FieldMap Map<String,RequestBody> params,来代替@PartMap来存储多张图片,只使用@FormUrlEncoded,但是发现请求接口,老是提示request参数不正确。

 问题二:

com.google.gson.stream.MalformedJsonException: Use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 1 path $

Gson gson = new GsonBuilder()
        .setLenient()
        .create();

    Retrofit retrofit = new Retrofit.Builder()
        .baseUrl("http://whatever.com")
        .addConverterFactory(GsonConverterFactory.create(gson))
        .build(); 

  https://stackoverflow.com/questions/27485346/malformedjsonexception-with-retrofit-api

 




posted on 2017-08-03 09:33  liyyanli  阅读(1314)  评论(0编辑  收藏  举报