無法發送的崗位API數據原始JSON數據使用Retrofit 2.0無法使用改造2.0
try {
JSONObject myUserData = new JSONObject();
myUserData.put("mobile", "917023847899");
myUserData.put("displayName", "Deepuu");
myUserData.put("info", "AD");
myUserData.put("photo", "");
myUserData.put("displayName", "Deepu");
JSONObject deviceData = new JSONObject();
;
deviceData.put("deviceId", "2124578910556991");
deviceData.put("pnToken", "klklklkl");
deviceData.put("os", "android");
deviceData.put("targetTopic", "jkjkjkjkj");
myUserData.put("device", "" + deviceData);
OkHttpClient client = new OkHttpClient();
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(URL)
.addConverterFactory(GsonConverterFactory.create())
.build();
Api Ainterface = retrofit.create(Api.class);
Call<Response> data = Ainterface.getResponse(myUserData);
data.enqueue(new Callback<Response>() {
@Override
public void onResponse(Call<Response> call, retrofit2.Response<Response> response) {
if (response.isSuccessful()) {
Response rr = response.body();
Integer ss = rr.getStatusCode();
Log.e("I Am", "Success" );
}
}
@Override
public void onFailure(Call<Response> call, Throwable t) {
Log.e("I Am", "Failed");
}
});
MyInterface的在POST
API數據發送原始JSON
數據:
@POST("appUsers/")
Call<Response> getResponse(@Body RequestBody value);
任何人都可以提出一個解決方案使用Retrofit 2.0
發送原始JSON
數據POST
api?我新使用Retrofit;請在onResponse
方法中獲得null
響應。
添加您的API和改造服務生成器類代碼太 – USKMobility
問題是我不能夠發送這些JSON對象perameters並得到空應答.. :( –