2017-05-02 78 views
0

我嘗試使用POST方法跟蹤URL。Android始終顯示500錯誤

URL:https://www.rampinteractive.com/api/app/sendmessage/313b4042-3bb3-4e2d-ad42-fd9103ebcdd9/32/-1/-1

方法:POST

參數:消息

但其形式數據請求。它的工作正常PostMan谷歌客戶端。檢查附加的屏幕截圖。但在Android中顯示500錯誤。請幫幫我。

enter image description here 的Android代碼:

Map<String, String> data = new HashMap<String, String>(); 
       data.put("message", edit_usedid.getText().toString().trim());    callAPI("https://www.rampinteractive.com/api/app/sendmessage/313b4042-3bb3-4e2d-ad42-fd9103ebcdd9/32/40940/1", data, APItype.CUSTOMER_LOGIN); 

Android的響應:

05-02 12:05:57.298 26211-26211/com.syzygy.extreme.sdealscustomer I/System.out: CUSTOMER_LOGIN URL is https://www.rampinteractive.com/api/app/sendmessage/313b4042-3bb3-4e2d-ad42-fd9103ebcdd9/32/40940/1 
05-02 12:05:57.299 26211-26211/com.syzygy.extreme.sdealscustomer I/System.out: Content-Type : text/html; charset=utf-8 
05-02 12:05:57.299 26211-26211/com.syzygy.extreme.sdealscustomer I/System.out: message : fsdfdsfsd 
05-02 12:05:57.594 26211-26744/com.syzygy.extreme.sdealscustomer E/Volley: [316] BasicNetwork.performRequest: Unexpected response code 500 for https://www.rampinteractive.com/api/app/sendmessage/313b4042-3bb3-4e2d-ad42-fd9103ebcdd9/32/40940/1 
05-02 12:05:57.595 26211-26211/com.syzygy.extreme.sdealscustomer I/System.out: onErrorResponse-CUSTOMER_LOGIN- null 
+0

android中使用什麼碼? – NehaK

+0

@NehaK代碼已更新。任何代碼都可以。請幫幫我。 – PREMKUMAR

+0

@PREMKUMAR,你檢查了這個:http://stackoverflow.com/questions/28135008/unexpected-response-code-500-for-post-method –

回答

0

我認爲問題是在你RequestProperty:

的Content-Type:text/html的;字符集= UTF-8

你應該設置爲應用/ JSON

@Override 
public Map<String, String> getHeaders() throws AuthFailureError { 
     Map<String, String> headers = new HashMap<>(); 
     headers.put("Content-Type", "application/json"); 
     return headers; 
}