2013-10-16 43 views
0

當有公佈的參數, 我們這樣做空的JSON對象POSTING

JSONObject postParams = new JSONObject("{ \"ccc\": \"20000\", \"abc\": \"21000\""}「);

DataOutputStream wr = new DataOutputStream(conn.getOutputStream()); 
      wr.writeBytes(postParams.toString()); 
      wr.flush(); 
      wr.close(); 
      int responseCode = conn.getResponseCode(); 
      System.out.println("\nSending 'POST' request to URL : " + url); 
      System.out.println("Post parameters : " + postParams); 
      System.out.println("Response Code : " + responseCode); 

如果心不是任何參數,我試圖做

JSONObject postParams = new JSONObject("{}"); 

它失敗了但是唯一的ID包含在鏈接裏面

https://domain.com/ut/game/game/trade/{UNIQUE ID HERE}/bid

有一些我錯過了我相信。

+0

爲什麼不只是'new JSONObject();'? –

+0

我想你錯過了問題部分... – BTC

+0

「It failed」 - 這是什麼意思?你有錯誤嗎? – Quentin

回答

1

如果沒有參數,那麼不要寫什麼conn.getOutputStream()

我不知道你的終點是什麼,但,這是有可能的情況下。