YouTube Data API v3 search JSON response retrofit parsing error

被刻印的时光 ゝ 提交于 2019-12-12 03:35:44

问题


YouTube Data API v3 search JSON response retrofit parsing error occurred

@GET("/youtube/v3/search")
void getYouTubeVideos(@Query("key") String apiKey,
                      @Query("channelId") String channelId,
                      @Query("part") String videoPart,
                      @Query("order") String videoOrder,
                      @Query("maxResults") String maxResults,
                      Callback<ChannelListResponse> callback);

for Callback<ChannelListResponse>

I have used

import com.google.api.services.youtube.model.ChannelListResponse

with dependency in gradle compile 'com.google.apis:google-api-services-youtube:v3-rev162-1.21.0'

but in failure method it returns error retrofit.RetrofitError: invalid value for field

plz guide me for better Thanks In advance


回答1:


I solved it by creating custom pojo class relevant to desired data because com.google.api.services.youtube.model.ChannelListResponse is not having any @Expose annotation nor @SerializedName() that's why parsing is not being successful.




回答2:


I think the problem is with this line: @Query("maxResults") String,maxResults. Check in the documentation and you will see that maxResults is not expecting a String but an unsigned integer.



来源:https://stackoverflow.com/questions/35364421/youtube-data-api-v3-search-json-response-retrofit-parsing-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!