如何使用 jboss 保险丝连接器更新 ServiceNow table
How to update ServiceNow table using jboss fuse connector
输入 JSON 到 REST API
`{
"userName" : "UserName",
"password" : "Password",
"instance" : "Instance Name",
"table":"incident",
"sysId": "9d385017c611228701d22104cc95c371",
"model":"{'assigned_to':'681b365ec0a80164000fb0b05854a0cd','urgency':'2','comments':'Elevating urgency, this is a blocking issue'}"
}`
处理器包含以下 headers:
` Map<String, Object> headers = new HashMap<>();
headers.put(ServiceNowConstants.ACTION, ServiceNowConstants.ACTION_UPDATE);
headers.put(ServiceNowConstants.RESOURCE, "table");
headers.put(ServiceNowConstants.TABLE, msg.getTable());
headers.put(ServiceNowConstants.SYSPARM_ID , msg.getSysId());
headers.put(ServiceNowConstants.MODEL, msg.getModel());
exchange.getOut().setHeaders(headers);`
Spring Camel 上下文 Bean 文件具有端点:
`servicenow://${header.instance}?userName=${header.name}&password=${header.password}&apiUrl=${header.apiUrl}`
输出:
`<h2>HTTP ERROR 500</h2>
<p>Problem accessing /servicenow/update. Reason:
<pre>model must be specified</pre>`
CamelServiceNowModel 在文档中被称为 Class,但是没有相同的实现。请帮助将模型 String/Class 放置在正确的位置以在 ServiceNow 中更新。
根据 ServiceNow REST API 的文档,POST/PATCH 操作,数据应该在 Body
中发送
This is solved with below snippet
Map<String, Object> body = new HashMap<>();
body.put("short_description", msg.getShort_description());
body.put("priority", msg.getPriority());
exchange.getOut().setBody(body);
ServiceNowConstants.MODEL 接受字符串(class 路径)
headers.put(ServiceNowConstants.MODEL, "java.util.HashMap");
输入 JSON 到 REST API
`{
"userName" : "UserName",
"password" : "Password",
"instance" : "Instance Name",
"table":"incident",
"sysId": "9d385017c611228701d22104cc95c371",
"model":"{'assigned_to':'681b365ec0a80164000fb0b05854a0cd','urgency':'2','comments':'Elevating urgency, this is a blocking issue'}"
}`
处理器包含以下 headers:
` Map<String, Object> headers = new HashMap<>();
headers.put(ServiceNowConstants.ACTION, ServiceNowConstants.ACTION_UPDATE);
headers.put(ServiceNowConstants.RESOURCE, "table");
headers.put(ServiceNowConstants.TABLE, msg.getTable());
headers.put(ServiceNowConstants.SYSPARM_ID , msg.getSysId());
headers.put(ServiceNowConstants.MODEL, msg.getModel());
exchange.getOut().setHeaders(headers);`
Spring Camel 上下文 Bean 文件具有端点:
`servicenow://${header.instance}?userName=${header.name}&password=${header.password}&apiUrl=${header.apiUrl}`
输出:
`<h2>HTTP ERROR 500</h2>
<p>Problem accessing /servicenow/update. Reason:
<pre>model must be specified</pre>`
CamelServiceNowModel 在文档中被称为 Class,但是没有相同的实现。请帮助将模型 String/Class 放置在正确的位置以在 ServiceNow 中更新。
根据 ServiceNow REST API 的文档,POST/PATCH 操作,数据应该在 Body
中发送This is solved with below snippet
Map<String, Object> body = new HashMap<>(); body.put("short_description", msg.getShort_description()); body.put("priority", msg.getPriority()); exchange.getOut().setBody(body);
ServiceNowConstants.MODEL 接受字符串(class 路径)
headers.put(ServiceNowConstants.MODEL, "java.util.HashMap");