我要複製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));
感謝
您是否在清單中添加了Internet Permision? – acostela
這是什麼意思,400?你從哪裏得到的? – greenapps
'我必須複製thia curl comand'。你忘了解釋這個curl命令在做什麼。該命令中的'文件'在哪裏? – greenapps