我必须在Android中复制thia curl comand:
curl -X POST -F gps_track=@ANTON_MORODER.igc https://myserver -H“api-name:name”-H“api-key:key”-H“user-key:user”-H“内容类型:application / json“
我有几种方式,但总是从服务器获得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 :(得分:0)
取代: 接受 - >内容类型