我正在尝试通过Amazon服务器将电子邮件作为Raw邮件发送。我已经用Java实现了这个应用程序,它正常工作。但是如果我在android中使用相同的代码我会得到400作为错误请任何机构建议我如何为http请求获取正确的标题?
String dataBytes = encodedReqPayload;
dataBytes=URLEncoder.encode(encodedReqPayload,"UTF-8");
uc.setRequestMethod("POST");
uc.setRequestProperty("Host", "email.us-east-1.amazonaws.com");
// uc.setRequestProperty("ContentType", "application/x-www-form-urlencoded");
uc.setRequestProperty("Content-Language", "en-US");
uc.setRequestProperty("x-amz-date",date_1);
uc.setRequestProperty("X-Amzn-Authorization",str);
uc.setRequestProperty("charset", "utf8 ");
uc.setDoOutput(true);
uc.setDoInput(true);
uc.setUseCaches(false);
uc.setConnectTimeout(1000 * 5);
uc.setFixedLengthStreamingMode(dataBytes.length());
uc.usingProxy();
uc.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
uc.setRequestProperty("Content-Length", "" + dataBytes.getBytes().length);
uc.setRequestProperty("Content-Language", "en-US");
//uc.setRequestProperty("Body",""+dataBytes);
uc.setUseCaches(false);
uc.setDoInput(true);
uc.setDoOutput(true);
uc.setAllowUserInteraction(true);
uc.setInstanceFollowRedirects(true);
OutputStreamWriter writer = new OutputStreamWriter(uc.getOutputStream());