Getting Error Constructing REST Message
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-06-2019 08:06 AM
Hi,
I am trying to set up a REST webservice with a customer using JIRA. When I set up the Outbound webservice and enter the HTTP request and click test it is successful, taking the values of variable substitutions.
I have a business rule running to try and get these variables to complete dynamically based on the information in the ticket that was logged. When I check the logs I get the below message;
'EXCEPTION during ESPCollinson.prepareMessage(Request, post):
Error constructing REST Message/Method: Collinson - Request/post'
If i put this BR into background scripts then I get a larger error message;
'org.mozilla.javascript.EcmaError: Cannot read property "short_description" from null
Caused by error in script at line 5
2:
3: // Add your code here
4: var message = ESPCollinson.prepareMessage('Request', 'post');
==> 5: message.setStringParameterNoEscape('ShortDesc', current.short_description);
6: message.setStringParameterNoEscape('Description', ESPCollinson.jsonEscape(current.description));
7: gs.log('RB - Im here in Collinson REST New Incident');
8: })(current, previous);
org.mozilla.javascript.EcmaError: Cannot read property "short_description" from null
Caused by error in script at line 1
==> 1: (function executeRule(current, previous /*null when async*/) {
2:
3: // Add your code here
4: var message = ESPCollinson.prepareMessage('Request', 'post');'
My gs.log is printed in the script logs.
I have attached my HTTP request in the REST message and the script include I'm using as a helper (this is how it has been done in the past for other REST integrations).
Any help would be greatly received.
Thanks,
Rob
- Labels:
-
Incident Management
-
Service Desk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-06-2019 08:15 AM
Hi Rob,
what type of Business rule it is?
the error means it is trying to get short_description from a null object;
is that table having short_description field?
Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-07-2019 03:13 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-07-2019 03:59 AM
Hi Robert,
why to have this as before insert and not async
async business rules are recommended whenever you want to trigger some API call to 3rd party from BR
Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-08-2019 02:18 AM
Hi Ankur,
I tried async but that didn't seem to make any difference i still got the same error message.
Thanks,
Rob