私は使用しており、データを使用してリクエストをRoboSpice Google Http Java Client module
正常に実行しています。POST
JSON
問題: 私の問題は、リクエストにbyte[]
データを添付する必要POST
があることですが、これを行う方法が見つかりませんRoboSpice Google Http Java Client module
。
ここに私のコードスニペットがあります:
public class SaveUserProfile_Request extends GoogleHttpClientSpiceRequest<SaveUserProfile> {
private String apiUrl;
private JSONObject mJsonObject;
private String filePath;
public SaveUserProfile_Request(JSONObject mJsonObject, String filePath) {
super(SaveUserProfile.class);
this.apiUrl = AppConstants.GLOBAL_API_BASE_ADDRESS + AppConstants.API_SAVE_PROFILE;
this.mJsonObject = mJsonObject;
this.filePath = filePath;
}
@Override
public SaveUserProfile loadDataFromNetwork() throws IOException {
Ln.d("Call web service " + apiUrl);
HttpRequest request = getHttpRequestFactory().buildPostRequest(new GenericUrl(apiUrl),
ByteArrayContent.fromString("application/json", mJsonObject.toString()));
request.setParser(new JacksonFactory().createJsonObjectParser());
return request.execute().parseAs(getResultType());
}
}
使ってみMultipart HTTP Requests
たけどダメ。