Outbound REST error - working in Postman

Cheri M
Kilo Sage

Hello all,

I am developing in Madrid. I wrote an outbound REST API to an endpoint that is NOT behind a firewall. I receive the error "Unknown Host" and error code 1 in the Test UI, in the logs the error is [ERROR CODE: -1 ]. I copy the code and endpoint in Postman and receive the correct response. At first I thought it might be headers but I pretty much just copied the headers from Postman and received the same results (unknown host).  I can go directly to the endpoint url in a browser and see the data. What am I doing wrong?

1 ACCEPTED SOLUTION

DScroggins
Kilo Sage

Hi Cheri,

 

If you get the 'unknown host' error then the SN instance cannot reach the endpoint. Im assuming the browser you are using to validate the endpoint is connected to a company network? If so can you try to access the endpoint via a device not connected to the same network i.e. take your phone off wifi and then use the cellular network to access. If you are still able to reach the endpoint then you know there is a problem with the Outbound REST message from the SN side. If you are not able to reach using the non-network connected device then you know that SN is unable to reach the endpoint and will need to utilize a MID server.

 

Hope this helps.

 

--David

View solution in original post

8 REPLIES 8

Cheri M
Kilo Sage

Not using a midserver for this first test.  The Web API is open and I can get to it in a web browser (it's one record).

Screenshot and the sample code the outbound API spits out.

find_real_file.png

try { 
 var r = new sn_ws.RESTMessageV2('Locations', 'GET');
 r.setStringParameterNoEscape('id', '');
 r.setStringParameterNoEscape('state', '');
 r.setStringParameterNoEscape('addressline1', '');
 r.setStringParameterNoEscape('country', '');
 r.setStringParameterNoEscape('addressline2', '');
 r.setStringParameterNoEscape('name', '');
 r.setStringParameterNoEscape('zipcode', '');
 r.setStringParameterNoEscape('city', '');

//override authentication profile 
//authentication type ='basic'/ 'oauth2'
//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 the message is configured to communicate through ECC queue, either
//by setting a MID server or calling executeAsync, one needs to set skip_sensor
//to true. Otherwise, one may get an intermittent error that the response body is null
//r.setEccParameter('skip_sensor', true);

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

DScroggins
Kilo Sage

Hi Cheri,

 

If you get the 'unknown host' error then the SN instance cannot reach the endpoint. Im assuming the browser you are using to validate the endpoint is connected to a company network? If so can you try to access the endpoint via a device not connected to the same network i.e. take your phone off wifi and then use the cellular network to access. If you are still able to reach the endpoint then you know there is a problem with the Outbound REST message from the SN side. If you are not able to reach using the non-network connected device then you know that SN is unable to reach the endpoint and will need to utilize a MID server.

 

Hope this helps.

 

--David

The other possibility is that the endpoint is restricting access via IP range and utilizing either your browser or locally installed Postman has the allowed IP range whereas the SN does not. The 'cellular' network test will also validate that as a culprit. 

Thanks David. My problem was I didn't know Postman was client based. I thought it was also in the cloud! I just installed the mid server (this is a new implementation) and it works perfectly. I guess I should have just waited for the mid server before I tried!