Skip to content
Advertisement

Tag: retrofit

Retrofit: How to wait for response

I have AsyncTask and the doInBackground method inside which, I sending POST request using Retrofit. My code looks like: The problem is: Retrofit sending request asynchronously and while it, the doInBackground method returning the value. So I need to send a request in the same thread with all executions in the sequence. One by one. And returning from doInBackground occurs

Logging with Retrofit 2

I’m trying to get the exact JSON that is being sent in the request. Here is my code: But I only see this in the logs: How am I supposed to do proper logging, given the removal of setLog() and setLogLevel() which we used to use with Retrofit 1? Answer In Retrofit 2 you should use HttpLoggingInterceptor. Add dependency to

Unable to create call adapter for class example.Simple

I am using retrofit 2.0.0-beta1 with SimpleXml. I want the retrieve a Simple (XML) resource from a REST service. Marshalling/Unmarshalling the Simple object with SimpleXML works fine. When using this code (converted form pre 2.0.0 code): Service: I get this exception: What am i missing? I know that wrapping the return type by a Call works. But I want the

How to send byte[] array in retrofit

How do you send byte[] array in retrofit call. I just need to send over byte[]. I get this exception when I have been trying to send a retrofit call. retrofit.RetrofitError: retrofit.converter.ConversionException: com.google.gson.JsonSyntaxException: java.lang.IllegalStateException:  Expected a string but was BEGIN_OBJECT at line 1 column 2 What is the way I can make the call using retrofit. I was simply passing byte array as a ByteMessage encapsulated in the

HTTP GET with request body RETROFIT

I am using Retrofit to make api calls in my android application. I have to submit a @Body of JSON I get error message Have you any idea? Answer To send data along with your Get Request you can do the following: as said in this SO answer, Server semantics for GET, however, are restricted such that a body, if

Declaring a retrofit REST endpoint with constant query value

So I want to get the metadata of a youtube video (say this one: https://www.youtube.com/watch?v=qlTA3rnpgzU). I’m going to encode it and wrap it in another url like so: http://www.youtube.com/oembed?url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DqlTA3rnpgzU&format=json My interface definition will look like this: That’s all fine and dandy, but I don’t ever want to specify any format other than JSON here (format=json is a fixed part of

Advertisement