Work with ECC queue

sanjeevkumar
Tera Contributor

Hi Team,

 

I need your assistance to create request in ECC queue so that mid server can process it further. Basically, We need to trigger create request to end point. We have to process Output and Input by ECC queue only. Can somebody help me out with that?

 

1 REPLY 1

Ratnakar7
Mega Sage
Mega Sage

Hi @sanjeevkumar ,

 

To create a request in the ECC queue, you can follow these steps:

  1. Define the payload: Determine the data and format you need to send to the endpoint. This could be in the form of a JSON, XML, or any other format required by the endpoint.

  2. Create an Outbound REST Message: In ServiceNow, set up an Outbound REST Message that defines the details of the endpoint you want to communicate with. This includes the URL, HTTP method (e.g., POST), headers, authentication, and the payload format.

  3. Create a Script: Write a script to trigger the creation of a request in the ECC queue using the ECCQueue API. Here's an example:

 

var restMessage = new sn_ws.RESTMessageV2();
restMessage.setEndpoint('<outbound_rest_message_sys_id>');
restMessage.setHttpMethod('POST');
restMessage.setRequestHeader('Content-Type', 'application/json');
restMessage.setRequestBody('<payload>');

var response = restMessage.execute();
var responseBody = response.getBody();

var eccQueueGR = new GlideRecord('ecc_queue');
eccQueueGR.initialize();
eccQueueGR.topic = 'your_topic_name';
eccQueueGR.name = 'your_request_name';
eccQueueGR.agent = 'mid_server_name';
eccQueueGR.source = 'your_source_name';
eccQueueGR.payload = responseBody;
eccQueueGR.insert();

 

replace <outbound_rest_message_sys_id> with the sys_id of the Outbound REST Message, and <payload> with the actual payload you want to send.

Make sure you have the correct values for 'your_topic_name', 'your_request_name', 'mid_server_name', and 'your_source_name'.

 

If my response was helpful in resolving the issue, please consider accepting it as a solution by clicking on the Accept solution button and giving it a thumbs up 👍. This will benefit others who may have a similar question in the future.

 

Thank you!

Ratnakar