Skip to main content

I have a REST Connector.

On Error, I would like to Notify admins.

I’d like to include the body of the Response in the email message.

 

The documentation for the Notify connector says you can use ArcScript.

 

But it doesn’t seem to do anything: The email I get is

File ES501_JE501_IN323078978944_ITMREF_20230720221100_20230720224809_47c0ddca-729b-43a6-833d-4466c9d422b11.json was routed to notification connector Notify2.

<arc:set attr="in.file" value="afilepath]" /> <arc:call op="fileRead" in="in" out="out" >
<!-- Here is where you can access the content of the file via the 'file:data' param. -->
<arc:set attr="output.data" value="aout.file:data]" />
</arc:call>

We attempted to send this to Atlas

 

How do I use ArcScript in the message?

This is something that is possible in the latest releases of CData Arc, including the most recently published 2023 update (contemporary to this post) at https://arc.cdata.com/order/ because it involves the use of a relatively recent feature of the REST connector, the Response event. 

 

Ordinarily, when a connector fails and routes a message down the Show Error Path, an X-Trapped-ErrorDescription header is added to the message, which can be resolved later in the flow, but for REST, this is going to include only the exception raised by the REST connector. As an example, if you POST a dummy file to the built-in /pub/Receive.rsb endpoint, that header would be something like:

 

cREST3: 2023-07-25T09:14:40-04:00] HTTP protocol error. 400 Bad Request.

 

If you are using a release where the Response event is available in the REST connector, however, it’s very easy with an additional line of code to add an additional header with the HTTP response. There is a special _response item available in the Response event that you can read from, so adding a new header with the response body is as simple as this line of code: 

<!-- Code goes here -->
<arc:set attr="_message.header:responsebody" value=""_response.body]" />

 

This header will accompany the message when it is routed to the Notify connector:

 

 

From within the Notify connector, you can use the %Header:headername% macro to resolve those headers in the body of an email that you send:

 

 


Reply