Reading an RSS feed using web services does not bring expected results


Description

Accessing a RSS feed endpoint in a browser window returns correct results in JSON however, when reading RSS feed content of same endpoint via an outbound REST web service as shown below, the response body does not bring expected response in JSON rather it returns an HTML doc results.

function RSS_Feed_Reader(rss_feed) {
    var end_point = rss_feed + "";

    var r = new sn_ws.RESTMessageV2();
    r.setEndpoint(end_point);
    r.setHttpMethod("GET");
    r.setRequestHeader("Accept", "application/json");
    var response = r.execute();

    var responseBody = response.getBody();
    var httpStatus = response.getStatusCode();

    gs.print('JSON Response Body: \n\n' + responseBody);
}

RSS_Feed_Reader(rss_feed); //Replace rss_feed with your RSS feed endpoint

Expected outcome for example is something like below but above API call returns an HTML doc:

{"current":{"health":1,"subject":"Hello World"}}


Release or Environment

Any release!

Cause

The RSS feed end point is asking for authentication which is why web service call returns an HTML doc. Try accessing RSS feed endpoint in an private/incognito browser window and you will experience the same behaviour.

Resolution

Please check with RSS feed endpoint administrator for the following possibilities/scenarios:

a) 1st API to first get authenticated
b) 2nd API call to access RSS endpoint

Asking for available API documentation for RSS Feed endpoint will also answer above questions.