REST API with MidServer

balaji_prusty1
Giga Guru

Hi All;

Thanks in advance !!!

I need to connect the Rest API which is in my office Intranet. But when I tried to   test connection (Post method) from ServiceNow to that API it gives error "java.net.ConnectException: Connection refused (Connection refused) when posting to".

As per me, as the API is in intranet and ServiceNow is in cloud, so ServiceNow is not able to access that API. I think this need to achieve by Mid Server. But I am not sure how to configure this.

Can anyone please help me on this.

Thanks

Balaji Prusty

4 REPLIES 4

VaranAwesomenow
Mega Sage

Dear Balaji,



Please refer to below documentation to install the midserver



https://docs.servicenow.com/bundle/jakarta-it-operations-management/page/product/mid-server/concept/...



Midserver should be installed on a machine which is within the intranet.



Once you install midserver you need to use that in REST API configuration (HTTP Method), as you can see from below screenshot.


find_real_file.png


Happy to help if you have further questions.


Thanks Anil;



Let me configure accordingly.


If you're doing the rest call from a script, you can also use the `setMIDServer` method.



e.g.


//snip setup of restMessage


var midServer = 'string name of MID server'; //not sys_id


restMessage.setMIDServer(midServer);


//snip execute and handling



Hope this can help.



Jarod


Suhas9
ServiceNow Employee
ServiceNow Employee

Hi,

I am facing the same issue, can someone please guide me:

The request failed: java.net.ConnectException: Connection refused: connect when posting to http://127.0.0.1:3000/add/5/5

 

 

Thanks & Regards,

Suhas Nayak