2015-08-28 26 views
0

我要複製Android中硫捲曲COMAND:HTTP POST在Android上頭和文件

捲曲-X POST -F [email protected]_MORODER.igc https://myserver -H 「API名稱:名稱」 -H「 API鍵:鍵」 -H 「用戶鍵:用戶」 -H 「內容類型:應用程序/ JSON」

我tyed幾種方式,但總是從服務器獲取400:

HttpClient httpclient = new DefaultHttpClient(); 
    HttpPost httppost = new HttpPost(doarama_api_url+"/activity"); 
    httppost.setHeader("api-name",api_name); 
    httppost.setHeader("api-key",api_key); 
    httppost.setHeader("user-key", AppSettings.getdoaramatUserKey()); 
    httppost.setHeader("Accept", "application/json"); 
    InputStreamEntity reqEntity = new InputStreamEntity(new FileInputStream(inIGC), -1); 
    reqEntity.setContentType("binary/octet-stream"); 
    reqEntity.setChunked(true); // Send in multiple parts if needed 
    httppost.setEntity(reqEntity); 
    HttpResponse response = httpclient.execute(httppost); 
    StatusLine statusLine = response.getStatusLine(); 
    int statusCode = statusLine.getStatusCode(); 
    Log.d("DOARAMA", "statusCode: " + String.valueOf(statusCode)); 

感謝

+0

您是否在清單中添加了Internet Permision? – acostela

+0

這是什麼意思,400?你從哪裏得到的? – greenapps

+0

'我必須複製thia curl comand'。你忘了解釋這個curl命令在做什麼。該命令中的'文件'在哪裏? – greenapps

回答

0

替換: 接受 - >內容類型

+0

感謝但相同的結果...狀態碼400 – user2030490

+0

雖然這可能回答OP的問題,但幾個解釋的話會使這個甚至對當前和未來的讀者更容易理解。 – Thom