I'm trying to perform a SSJS HTTP GET request to an endpoint that uses "OData", however the call fails (Cloud Page doesn't load). The SSJS GET function in question (seen below) is the only code on the page, there are no other factors.
I need to use the SSJS GET Request for my solution as the endpoint requires the "Auth Bearer Token" Headers; and headers are not able to be passed in AMPScript's GET Request.
Has anyone got a GET or POST request to an OData endpoint working in SSJS?
Sample Code and Documentation:
You can read more about the OData type here.
The documentation on the above link provides an example endpoint. You can call that endpoint in AMPScript as follows:
%%[
SET @get = HTTPGet('https://services.odata.org/v4/TripPinServiceRW/People',false,0,@CallStatus)
]%%
%%=v(@get)=%%
Output:
{"@odata.context":"http://services.odata.org/V4/(S(c4psssbydvwflieflsouvwqs))/TripPinServiceRW/$metadata#People","@odata.nextLink":"https://services.odata.org/V4/(S(c4psssbydvwflieflsouvwqs))/TripPinServiceRW/People?%24skiptoken=8.... etc
AMPScript GET Documentation
The following SSJS code is what is failing on my Cloud Page; despite being a function replication of the AMPScript code above:
<script runat="server">
Platform.Load("Core","1.2");
try{
var responseContent = HTTP.Get('https://services.odata.org/TripPinRESTierService/People');
Write(Stringify(responseContent));
}
catch(error) {
Write('Message: '+ error);
}
</script>