안전한 안심할 수있는 웹 서비스를 통해 노래 (mp3/wav) 파일과 일부 데이터를 전송한다고 가정합니다. MultipartEntity를 사용하여 HttpPost 요청을하고 있습니다. 메시지 상태 보고서 : 잘못된 요청 클라이언트가 보낸 요청의 구문이 잘못되었습니다 (잘못된 요청) 잘못된 요청 유형 - 나는 HttpClient를 통해 실행할 때, 서버는이 오류안드로이드 오류 : MultipartEntity, 클라이언트가 보낸 요청이 구문 상 올바르지 않음
에게 HTTP 상태 400 응답합니다.
그러나 웹 인터페이스에서 호출하면 서비스가 잘 수행됩니다.
의 코드
HttpClient httpclient = new DefaultHttpClient();
HttpPost postRequest = new HttpPost();
try {
MultipartEntity reqEntity = new MultipartEntity();
reqEntity.addPart("email", new StringBody("[email protected]"));
reqEntity.addPart("password", new StringBody("123"));
reqEntity.addPart("title", new StringBody("My new song"));
reqEntity.addPart("musicData", new FileBody(new File(FilePath)));
// FIlePath is path to file and contains correct file location
postRequest.setEntity(reqEntity);
postRequest.setURI(new URI(ServiceURL));
HttpResponse response = httpclient.execute(postRequest);
} catch (URISyntaxException e) {
Log.e("URISyntaxException", e.toString());
}
나는 또한 MultipartEntity에 대한 아파치 mime4j, HttpClient를, httpcore 및 httpmime 단지를 포함 도와주세요.
이것은 서비스의 HTML 페이지 스냅입니다.
인증이 제대로 작동합니까? – Mark
예 ..... 그렇습니다 – Azhar
웹 서비스에도 매핑 URL을 게시 할 수 있습니까? URL 요청이 매핑 한 것과 다를 수 있습니다. – tolgap