指定されたアドレスにPOSTリクエストを再送信したいのですが、たとえば
POSTリクエストの場合、ユニバーサルメソッドを作成しました。
private String postMethod(String url, HashMap<String, String> headers, String encodedAuthorizationString) throws HttpException, IOException {
HttpClient client = new HttpClient();
PostMethod post = new PostMethod(url);
post.setRequestHeader("Authorization", encodedAuthorizationString);
if(headers != null && !headers.isEmpty()){
for(Entry<String, String> entry : headers.entrySet()){
post.setRequestHeader(new Header(entry.getKey(), entry.getValue()));
}
}
client.executeMethod(post);
String responseFromPost = post.getResponseBodyAsString();
post.releaseConnection();
return responseFromPost;
}
ここで、headersはペア(key、value)を表します(例: "product [title]"、 "TitleTest")。postMethod( " http://staging.myproject.com.products.xml "、headers、 "xxx");を呼び出してメソッドを使用しようとしました。ヘッダーにペアが含まれている場合
("product [title]"、 "TitleTest")、
("product [content]"、 "TestContent")、
(product [price]、 "12.3")、
("タグ"、 "aaa、bbb")
しかし、サーバーはエラーメッセージを返しました。
誰かがアドレスを解析する方法を知っていますか
上記の方法で使用するには?URLはどの部分ですか?パラメータは正しく設定されていますか?
ありがとうございました。