The server API takes a JSON array in the request body. Like this:
[
{
"key1" : "value1",
"key2" : "value2",
"key3" : "value3"
}
]
I know how to put a JSON object as the body, but how can I put a JSON array in a retrofit request?
I already have a POJO:
public class Sample {
@SerializedName("key1")
@Expose
private String key1;
@SerializedName("key2")
@Expose
private String key2;
@SerializedName("key3")
@Expose
private String key3;
}
Here's my API class:
@PATCH("//some url")
Observable<ResponseBody> patchRequest(
// ... other params
@Body Sample sampleBody;
);
When I make a request, the body looks like this:
{
"key1" : "value1",
"key2" : "value2",
"key3" : "value3"
}
Except I need it to be inside an array as show in the first JSON.