- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-04-2015 07:54 AM
Looks like it was hitting an error when I was trying to escape the quotation marks in the value for "environments". Here, this passes the syntax check:
var postString = "{\"deployment\":\"CHG1111112-Fri April 29 14:00:00 CST 2015\", \"project\":\"SNOWTest\", \"build\":\"1.0.0\", \"application\":\"Tomcat Generic\",\"environments\":\"[\\\"Environment for Default Architecture\\\"]\", \"deploymentPlan\":\"Ken Prior\"}";
var response = r.execute(postString);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-03-2015 09:52 AM
Hi Kenneth,
It looks like the error is being returned form the external web service because it doesn't like what you sending. You should check what you have configured for this Outbound REST message to see what you have as the content. from the error it seems to be complaining about an "&" character
{"result":false,"description":"Could not read JSON: Unexpected character ('&' (code 38)): expected a valid value (number, String, array, object, 'true', 'false' or 'null')\n at [Source: org.apache.catalina.connector.CoyoteInputStream@1b92a907; line: 1, column: 18]Hope this helps.
-Jose
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-04-2015 06:03 AM
Actually this exact data elements works just fine in the REST test message per the REST configuration, just not from the Run Script.
The parameters have been checked and re-checked at let 20 times, and tested with the apostrophe and without, as well as the Quote marks. But they are the same as the preview script data from the REST setup page as well.
Without the apostrophe and quote marks the error is diferrent error.
Thanks though.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-04-2015 06:41 AM
The parameters have been checked and re-checked at let 20 times, and tested with the apostrophe and without, as well as the Quote marks. But they are the same as the preview script data from the REST setup page as well.
Without the apostrophe and quote marks the error is diferrent error.
{"result":false,"description":"Could not read JSON: Unrecognized token 'Tomcat': was expecting ('true', 'false' or 'null')\n at [Source: org.apache.catalina.connector.CoyoteInputStream@8775e8a; line: 1, column: 24]; nested exception is com.fasterxml.jackson.core.JsonParseException: Unrecognized token 'Tomcat': was expecting ('true', 'false' or 'null')\n at [Source: org.apache.catalina.connector.CoyoteInputStream@8775e8a; line: 1, column: 24]"}
Essentially it appears that when removing the apostrophe or quote marks it does not get the formatted data as expected. The service I am sending this to expects the quotes around the data as part of the string sent, and by removing one or the other it does not see these. it is passed as a string without the quotes in the data.
With the apostrophe and quote marks then I get the first error above.
Hope this clarifies it a little. I need to pass a string including quotes as such: "Tomcat Generic" to the receiving system. It expects a value that is in quotes so I need to pass the string to look as it is here.
Thanks to all who have attempted to help so far and those brave souls who will continue!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-05-2015 12:26 PM
I had to change my call to NoEscape in my case.
try {
var r = new sn_ws.RESTMessageV2('Nolio Deployment', 'post');
r.setStringParameterNoEscape('application', '"' + current.u_app + '"');
r.setStringParameterNoEscape('build', '"' + current.u_build + '"');
r.setStringParameterNoEscape('project', '"' + current.u_nolio_project + '"');
r.setStringParameterNoEscape('deploymentPlan', '"' + current.u_deployment_plan + '"');
r.setStringParameterNoEscape('environments', '["' + current.u_environments + '"]');
r.setStringParameterNoEscape('deployment', '"' + current.u_deployment + '"');
var response = r.execute();
var responseBody = response.getBody();
var httpStatus = response.getStatusCode();
var parser = new JSONParser();
var parsed = parser.parse(responseBody);
current.u_nolio_results = "Result: " + parsed.result + String.fromCharCode(13) + "Description: " + parsed.description + String.fromCharCode(13);
}
catch(ex) {
var message = ex.getMessage();
}
Thanks all.