Calling third party APIs using mid server

Anuja12
Kilo Contributor

Hi, i need to call API endpoints from third party application into service now. I gave authentication as 'BASIC' for calling those apis and it asked for username and password, so i provided the username and password for the third party tool ,on clicking on Test it showed me some java.net host exception error. That's why now I want to fetch those APIs using mid server. I dont know how we use mid server? like i have installed it and connection and validation is done but how do we use this for calling APIs for third party application? I actually need step by step guidance as I am very new to this..-thanks in advance

12 REPLIES 12

MrMuhammad
Giga Sage

Hi @Anuja ,

Here are the steps.

  • Install the MID server on the host machine in Clients Network. 
  • Request Infrastructure/network team to allow network routing from MID server to Third-party App/server. In other words, the MID server should have access to the Third-party app.
  • In the REST script use r.setMIDServer('MY_MID_SERVER'). [r is sn_ws.RESTMessageV2]
  • Its done. Now your integration and communication with the third-party app is via MID server. 

See MID server installation instructions HERE.

Hope that helps!

Thanks & Regards,

Sharjeel

Regards,
Muhammad

Hitoshi Ozawa
Giga Sage
Giga Sage

Is the 3rd party service in your internal network? If it's on the public network, there's no need to use MID server.

If it's in your internal network, you'll need a MID server.

If the MID server is working without problem, all there is calling 3rd party REST API is to select the MID Server to use. Other settings do not change.

For example, in the Outbound > REST Message, select the HTTP Methods. Select HTTP Request tab. There should be a "Use MID Server" pull down list. Just select the MID server to use here. There's no other setting for the MID Server.

find_real_file.png

As usually, generate JavaScript source code by selecting "Preview Script Usage". As described in the generated code, you'll need to uncomment and set the following statement to use MID Server and Basic authentication.

//override authentication profile 
authentication type ='basic';
r.setAuthenticationProfile(authentication type, profile name);

//set a MID server name if one wants to run the message on MID
r.setMIDServer('MY_MID_SERVER');

If your service API requires Basic authentication, you'll need to select "Authentication" tab and set Authentication type to "Basic". This implies the service API requires Basic Authentication. There's no authentication for the MID server at the service api level. MID servers are "validated" when they are setup. 

https://docs.servicenow.com/bundle/orlando-servicenow-platform/page/product/mid-server/task/t_Valida...

 

 

  • okay so i gave the third party endpoint which is private.
  • installed mid server too ( i made sure both status and validation of MID server is UP and YES resp.)
  • here in REST message i gave authentication as BASIC (  in basic authentication I gave the username and password which is required for my third party APIs)
  • then i used mid server here ( just like you have shown in the screenshot).
  • after all these i clicked on TEST.

it is showing me this error :

"No response for ECC message request with sysid=caaf46682f5f1010f7ded5f62799b693 after waiting for 30 seconds in ECC Queue."

 

Am i missing something or did I do any mistake? Please guide me...

 

-thanks 

 

Can you test if you can call the 3rd party url from your MID server.

For example, use curl command to call the url.

If this results in an error, a firewall may be blocking access from MID server to the 3rd party service.