retrofit2

Retrofit 2 Multipart image upload with data

て烟熏妆下的殇ゞ 提交于 2020-01-10 20:13:10
问题 Hello everyone I want to post image and other data through Retrofit2. I am sending data with one image. All the other info is storing but my image is not storing.while i am testing with postman, it works. please guide me where I am lacking in my code This is the postman code snippet that works OkHttpClient client = new OkHttpClient(); MediaType mediaType = MediaType.parse("multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW"); RequestBody body = RequestBody.create(mediaType, "

how to display data of different api ids to different items of recycle view?

寵の児 提交于 2020-01-10 05:57:08
问题 I will briefly write what I exactly want and where I'm exactly stucked.I'm loading a list in recycleview from api using retrofit(which I have loaded successfully)see this image-->image description here. Further I have two api ids(example :https//..id=1 and https//..id=2 and so on depending upon this list image description here.) here is my 2 apis:(first one https//..id=1) {"id":"1","title":"Android Introduction","description":" Android is a Linux based operating system it is designed

Retrofit 2 - URL Query Parameter

不问归期 提交于 2020-01-09 09:13:09
问题 I am using a query parameters to set the values needed by the Google Maps API. The issue is I do not need the & sign for the first query parameter. @GET("/maps/api/geocode/json?") Call<JsonObject> getLocationInfo(@Query("address") String zipCode, @Query("sensor") boolean sensor, @Query("client") String client, @Query("signature") String signature); Retrofit generates: &address=90210&sensor=false&client=gme-client&signature=signkey which causes the call the fail when I need it to be address

How can I handle empty response body with Retrofit 2?

六眼飞鱼酱① 提交于 2020-01-09 02:57:06
问题 Recently I started using Retrofit 2 and I faced an issue with parsing empty response body. I have a server which responds only with http code without any content inside the response body. How can I handle only meta information about server response (headers, status code etc)? 回答1: Edit: As Jake Wharton points out, @GET("/path/to/get") Call<Void> getMyData(/* your args here */); is the best way to go versus my original response -- You can just return a ResponseBody , which will bypass parsing

how to run java and xml code (fetched from api) into another fragment

主宰稳场 提交于 2020-01-08 10:59:10
问题 okay I will breifly define what I exactly want.I'm getting an java code(for textview, button,etc) from api like this--> image description here and Xml code(for textview, button,etc)from api like this--> image description here..what I want is to run these java and xml and display it like this--> enter image description here.. I really have no idea how to do that..can anyone help..I will post up java/xml code and its adapters following please have look ..I haven't done anything in demo fragment

how to run java and xml code (fetched from api) into another fragment

时光毁灭记忆、已成空白 提交于 2020-01-08 10:58:49
问题 okay I will breifly define what I exactly want.I'm getting an java code(for textview, button,etc) from api like this--> image description here and Xml code(for textview, button,etc)from api like this--> image description here..what I want is to run these java and xml and display it like this--> enter image description here.. I really have no idea how to do that..can anyone help..I will post up java/xml code and its adapters following please have look ..I haven't done anything in demo fragment

How to retrieve web service values through Retrofit to text view?

微笑、不失礼 提交于 2020-01-07 08:07:13
问题 I'm developing an app and in first activity it has card view layout. I'm retrieving data from a webservice and relevant data are showed in card view. It's working well. Now when a user clicks a particular card view I need to go for another activity. I'm getting relevant ID for that card view and passing it to the second activity. In second activity I need to show the content according to that unique Id. But I'm not getting any thing. This is what I tried. Pojo class public class PromoDetails

Retrofit2 authentication error to IBM's Speech to Text

别等时光非礼了梦想. 提交于 2020-01-06 08:12:48
问题 I am trying to access IBM's Speech to Text service without using the library. I am using Retrofit with GSON. The issue is in the authentication, which apparently does not occur correctly, returning code 401. From the official documentation, the HTTP request should come in this format curl -X POST -u "apikey:{apikey}" \ --header "Content-Type: audio/flac" \ --data-binary @{path_to_file}audio-file.flac \ "{url}/v1/recognize" When I test the curl command with my credentials, the service works

Parsing JSON array that contain objects with different attributes with Retrofit

瘦欲@ 提交于 2020-01-06 07:12:09
问题 how can I parse JSON array that contains JSON objects without names and each object have his own attributes in Android with Retrofit2. Json is something like this: [ { "username":"alexruskovski", "age":27, "active":true }, { "languages":"Java", "occupation":"Programming", "phone_num":"123456789", "email":"asdf@qwe.com" } ] And I have my POJO's like this: user: public class User{ String username; int age; boolean active; } and here is the data object: public class Data{ String languages,

Pass requestBody to another request body using Map<String,RequestBody>

让人想犯罪 __ 提交于 2020-01-06 05:40:34
问题 My code is for send data to server using Multiform data. Code: Map<String, RequestBody> params = new HashMap<>(); params.put("devicetype", toRequestBody(Constants.DEVICE_TYPE)); params.put("deviceid", toRequestBody(Functions.getDeviceId(AddDetailsActivity.this))); params.put("appversion", toRequestBody(Constants.APP_VERSION)); params.put("apiversion", toRequestBody(Constants.API_VERSION)); params.put("timezone", toRequestBody(Functions.getTimeStamp())); params.put("modeltype", toRequestBody