Getting Error Constructing REST Message

Rob Bushrod
Tera Guru

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

6 REPLIES 6

Ankur Bawiskar
Tera Patron
Tera Patron

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

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Hi Ankur,

It is a before insert business rule running on the incident table, I have attached the images of when to run and advanced tab.

Thanks,

Rob

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

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Hi Ankur,

I tried async but that didn't seem to make any difference i still got the same error message.

Thanks,

Rob