[英]bad request(400) in mule http
below is my java code: 以下是我的Java代码:
Authenticator.setDefault(new MyAuthenticator(){
public PasswordAuthentication getPasswordAuthentication() {
return (new PasswordAuthentication(username, password.toCharArray()));
}
});
URL url = new URL(RestUriConstants.BUSINESS_PROCESS_BASE + businessProcessName);
URLConnection conn = url.openConnection();
conn.setDoOutput(true);
conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
conn.setRequestProperty("Accept","application/json");
OutputStreamWriter writer = new OutputStreamWriter(conn.getOutputStream());
writer.write(data);
writer.flush();
above data is: 以上数据为:
action=start¶ms={"input":{"claimNo":"9","status":"open","customerName":"Rajesh"}}&createTask=false&parts=all
行动=起始&PARAMS = { “输入”:{ “claimNo”: “9”, “状态”: “打开”, “客户名称”: “拉杰什”}}&的CreateTask =假零件=所有
this working fine. 这个工作正常。 same thing i implemented in Mule.
我在M子中实现的同样的事情。 I'm getting 400 error.
我收到400错误。 my mule configuration is below:
我的m子配置如下:
<set-variable variableName="url" value="#[json:url]" doc:name="Variable"></set-variable>
<set-variable variableName="param" value="action=start&params={"input":#[json:param]}&createTask=false&parts=all" doc:name="Variable"></set-variable>
<http:outbound-endpoint exchange-pattern="request-response" address="http://admin:admin@#[url.substring(7)]" method="GET" doc:name="HTTP">
<set-property propertyName="Content-Type" value="application/x-www-form-urlencoded"></set-property>
<set-property propertyName="Accept" value="application/json"></set-property>
<set-payload value="#[param]"/>
</http:outbound-endpoint>
<logger message="#['\n'+message.inboundProperties['http.status']]" level="INFO" doc:name="Logger"/>
my json is: 我的json是:
{"url":" http://mysystem.com:8080/rest/processData ","param":{"claimNo":"9","status":"open", "customerName":"Rajesh"}} {“ url”:“ http://mysystem.com:8080/rest/processData ”,“ param”:{“ claimNo”:“ 9”,“ status”:“ open”,“ customerName”:“ Rajesh”} }
thanks. 谢谢。
If you want to set POST variables, use method POST, and a payload of type Map. 如果要设置POST变量,请使用POST方法和Map类型的有效负载。 Like this:
像这样:
<set-payload value="#[['action':'start','params':param,'createTask':'false','parts':'all']]"/>
Variable "param" here of course just the JSON String you have as a one of the POST variables, not all your variables. 当然,这里的变量“ param”只是作为POST变量之一的JSON字符串,而不是所有变量。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.