Skip to content

Tag: retrofit2

GSON flat down map to other fields

So I have an Android app which uses Retrofit for API. I have a class like which looks like: When GSON creates a JSON it looks like: Would it be possible to change JSON serialization to: Thanks. Answer Here is how Gson could be used to implement the flattening: I’ve put some comments explaining “whats” and “hows”. But it would

I want to add a bearer token to my retrofit post request

I have an app that is to register people into a platform but I get a response of Unauthenticated each time I submit the form data. The form is submitted using an API which requires a bearer token for each post request with the aid of retrofit. I have been out of touch with Java. Note: its just a plain

Retrofit2, Android, @Get Parsing for the Array of Array

I am parsing the title correctly and displaying it in a listview. I cant seem to access the seen below. Here are the two objects, sample response and my call. response pojo: first object second object response: I am getting the title just by passing ‘result’ into the adapter and using result[i].getTitle(); I tried using result[i].Details[0].findMe; but my error response

Logging with Retrofit 2

I’m trying to get the exact JSON that is being sent in the request. Here is my code: OkHttpClient client = new OkHttpClient(); client.interceptors().add(new Interceptor(){ @Override public com….