yongjhih / NotRetrofit

Type-safe REST client for Android and Java
Apache License 2.0
93 stars 12 forks source link

can't emit raw string into request? #9

Open kenkyee opened 8 years ago

kenkyee commented 8 years ago

This is probably a strange request for a strange API that takes nonstandard JSON that had to be specially formatted.

Following this stackoverflow question: http://stackoverflow.com/questions/30515068/send-json-raw-object-retrofit

public class TypedJsonString extends TypedString {
    public TypedJsonString(String body) {
        super(body);
    }

    @Override public String mimeType() {
        return "application/json";
    }
}

The API looks like this:

    @POST("/fetch")
    public abstract AvailableCampaigns sendDataAndFetchCampaigns(
            @Retrofit.Header("User-Agent")
            String userAgent,
            @Retrofit.Query("Site_ID")
            String siteID,
            @Retrofit.Body
            TypedJsonString data);

I tried to use a TypedJsonString as well as a plain String but the LoganSquareConverter doesn't know how to handle either one. I just want a string passthru into the body. Any suggestions on how to do this?

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/28758477-can-t-emit-raw-string-into-request?utm_campaign=plugin&utm_content=tracker%2F8327951&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F8327951&utm_medium=issues&utm_source=github).
kenkyee commented 8 years ago

I ended up coding up a separate http request so didn't need to make NotRetrofit do this