Hello @rbiri
Are you sending this request to another AC instance or the same instance? If you are getting the data from same instance then there is a better way to do this.
Here is an example:
var recipients= xtk.queryDef.create(
<queryDef operation="select" schema="nms:recipient">
<select>
<node expr="@id"/>
<node expr="@email"/>
</select>
</queryDef>).ExecuteQuery();
for each(var recipient in recipients) {
// get your data here
}
If you are accessing another instance then you can use the code given here:
https://experienceleague.adobe.com/developer/campaign-api/api/c-HttpClientRequest.html