Request data from another ServiceNow instance

tsoct
Tera Guru

Hi all

I'm seeking ways to set up 'something' in instance A to request instance B to send data to instance A once per week. The data provided by instance B should go to the transform map in instance A before being populated in instance A.
Could somebody tell me how to go about doing this?

8 REPLIES 8

Omkar Kumbhar
Mega Sage
Mega Sage

Hello @tsoct ,

Please refer the below video which will help you.

https://www.youtube.com/watch?v=j3BVJAueXLM

Thanks,

Omkar

If I was able to help you with your case, please click the Thumb Icon and mark as Correct.
This video demonstrates the integration between two servicenow instances using a staging table and authentication type as basic.

tsoct
Tera Guru

Hello @Omkar Kumbhar ,

The video is about setting the POST/PUT method in the instance which should be providing the data. I am looking for a way for instance that request for data to trigger a request to instance B to provide data. REST should be set up in instance A. Any idea how should I do it?

Omkar Kumbhar
Mega Sage
Mega Sage

Hello @tsoct ,

1) Create a rest message in instance A consume the rest message of instance B.

OmkarKumbhar_0-1676560045306.png

 

Use the basic authenticate of instance B

later create the POST https method

Create the scheduled job and copy script 

OmkarKumbhar_1-1676560160289.png

 

Create the stagging table and map the data from response to stagging.

Later stagging table you can map it to target table.

 

Please try this approach and let me know if this works.

 

Thanks,

Omkar

 

If I was able to help you with your case, please click the Thumb Icon and mark as Correct.

tsoct
Tera Guru

Thank you, @Omkar Kumbhar ,

I completed the first step of creating the GET HTTPS in instance A, with the endpoint 'instanceB table API'. And the rest has me confused. Please be patient with me. 🙂

And here are my inquiries:
1) Should the endpoint of the POST https method be instance A's staging table? If no, how both POST and GET relate?
2) Is the scheduled job's script correct?

var org = gs.getProperty('instance_name');

var gn = new GlideRecord('sys_user_has_role');
while(gn.next()){
   var body ={
	"u_organization": org,
        "u_role": gn.role.getDisplayValue(),
        "state": gn.allocated_status.toString(),
       };

try {
        var r = new sn_ws.RESTMessageV2('Integrate instance B', 'Default GET');
        r.setRequestBody(JSON.stringify(body));

        var response = r.execute();
        var responseBody = response.getBody();
        var httpStatus = response.getStatusCode();
       
    } catch (ex) {
        var message = ex.message;
 
    }
}

 Thank you