CData REST RSD – How to Pass Dynamic Bearer Token and Parse JSON Array Response with jsonproviderGet

Hi,

I’m creating a custom CData REST RSD for the Cynet API and consuming it through Incorta.

The RSD performs two calls: first a POST to obtain the access token, then a GET to the Alerts endpoint using the Bearer token.

The login works and the token is populated (length is 857 characters). I also confirmed that httpGet retrieves the raw response body from the Alerts endpoint. However, jsonproviderGet returns 0 rows.

The response from the Alerts endpoint is structured like:

{  "SyncTimeUtc": "2026-09-28T06:28:02.0628506Z",  "Entities": [    {      "ClientDbId": 166,      "Uniqueness": "...",      "IncidentName": "Host Was Not Scanned",      "IncidentDescription": "..."    }  ]}

Here is the relevant RSD:

<api:script xmlns:api="http://apiscript.com/ns?v1"            xmlns:xs="http://www.w3.org/2001/XMLSchema">  <api:info title="CynetAlerts"            desc="Cynet alerts - rolling last 30 days"            xmlns:other="http://apiscript.com/ns?v1">    <attr name="ClientDbId"          xs:type="long"          columnsize="20"          readonly="true"          other:xPath="/json/Entities/ClientDbId" />    <attr name="Uniqueness"          xs:type="string"          columnsize="2000"          readonly="true"          other:xPath="/json/Entities/Uniqueness" />    <!-- additional attributes -->  </api:info>  <!-- Login configuration -->  <api:set attr="loginin.DataModel" value="DOCUMENT" />  <api:set attr="loginin.ConnectionType" value="HTTPS" />  <api:set attr="loginin.URI" value="access_token_uri" />  <api:set attr="loginin.AuthScheme" value="NONE" />  <api:set attr="loginin.ContentType" value="application/json" />  <api:set attr="loginin.EncodePostData" value="false" />  <api:set attr="loginin.XPath" value="/json" />  <api:set attr="loginin.ElementMapPath#1" value="/json/access" />  <api:set attr="loginin.ElementMapName#1" value="access" />  <api:set attr="loginin.data">  {      "accessKey": "XXXXX",      "secretKey": "XXXXX"  }  </api:set>  <api:set attr="tmp.token" value="" />  <api:set attr="loginin.method" value="POST" />  <api:call op="jsonproviderGet" in="loginin" out="loginout">      <api:set attr="tmp.token" value="[loginout.access]" />  </api:call>  <!-- Alerts -->  <api:set attr="alertsin.DataModel" value="DOCUMENT" />  <api:set attr="alertsin.ConnectionType" value="HTTPS" />  <api:set attr="alertsin.URI"           value="base_uri?LastSeen=2026-09-26%2000:00:00" />  <api:set attr="alertsin.JSONPath" value="$.Entities" />  <api:set attr="alertsin.method" value="GET" />  <api:set attr="alertsin.Header:Name#1" value="Authorization" />  <api:set attr="alertsin.Header:Value#1"           value="Bearer [tmp.token]" />  <api:set attr="alertsin.Header:Name#2" value="client_id" />  <api:set attr="alertsin.Header:Value#2" value="XXXXX" />  <api:call op="jsonproviderGet" in="alertsin" out="alertsout">      <api:push />  </api:call></api:script>

Could someone advise what is causing jsonproviderGet to return zero rows?

Specifically, I would like to confirm:

  • Is alertsin.JSONPath = "$.Entities" correct when Entities is an array?
  • Should the other:xPath values be /json/Entities/ClientDbId, etc., or should they be relative to each entity?
  • Should api:push explicitly reference alertsout?
  • Is using in="alertsin" with jsonproviderGet correct in this structure?

The HTTP GET itself is successful; the issue appears to be the JSON parsing/row generation.

Thanks.

2 Likes

Hi ​ @stalha.tariq ,

I am not seeing any issues with the Alert block so that should be good. For the authentication block, it can be simplified further to get down to a cleaner script but other than that it does look functional. The main issue is the XPath has not been defined correctly. Because for the JSONPath repeat element, that wildcard is *, whereas the wildcard is % for the column other:xPath values. Can you try making the changes below?

<api:info title="CynetAlerts" desc="Cynet alerts - rolling last 30 days" xmlns:other="http://apiscript.com/ns?v1"><attr name="ClientDbId"          xs:type="int"    columnsize="4"    precision="11"           readonly="false"              other:xPath="/json/%/ClientDbId"          /><attr name="IncidentDescription" xs:type="string" columnsize="2000"                          readonly="false"              other:xPath="/json/%/IncidentDescription" /><attr name="IncidentName"        xs:type="string" columnsize="2000"                          readonly="false"              other:xPath="/json/%/IncidentName"        /><attr name="Uniqueness"          xs:type="string" columnsize="2000"                          readonly="false"              other:xPath="/json/%/Uniqueness"          /></api:info>

The JSONPath for the Alerts block can be set as below:

<api:set attr="JSONPath" value="$.%" />

Also, you should indeed include the api:push item=“alertsout”

 <!-- Fetch the target data --> <api:call op="jsonproviderGet" in="alertsin" out="alertsout">      <api:push item="alertsout" />  </api:call>

Kindly give this a try and let me know if this resolves the issue.

Ethem’s % change is the important part: once JSONPath selects the repeating array, the column other:xPath should use % for the repeated item, not the literal Entities segment. Also use <api:push item="alertsout" />; a bare push can emit the current input rather than the named output. If it still yields zero rows, temporarily set JSONPath=$ and compare the raw row count—that will tell you whether the issue is the repeat path or the response/auth layer.

Hi @Ethem_Q/ @emilyjackson

Thank you for your response, I appreciate you both taking the time to look at this.

I tried the suggested changes. jsonproviderGet still returns 0 rows, but I’ve narrowed down where it fails. Here’s what I tested:

1. Suggested fix

  • Column paths changed to other:xPath="/json/%/ClientDbId" (and so on for all columns)
  • alertsin.JSONPath set to $.Entities, and also tried $.%
  • <api:push item="alertsout" />
  • Login block unchanged

Result: the load succeeds, but returns 0 rows.

2. Root-level test

  • alertsin.JSONPath = $
  • Added a column SyncTimeUtc with other:xPath="/json/SyncTimeUtc" (a top-level field in the response)

Result: 0 rows, so jsonproviderGet returns nothing even for the root object.

3. Same request with httpGet inside the same RSD

xml

 </api:set>
    <api:set attr="tmp.token" value="" />
    <api:set attr="loginin.method" value="POST" />
    <api:call op="jsonproviderGet" in="loginin" out="loginout">
      <api:set attr="tmp.token" value="[loginout.access]" />
    </api:call>

<api:set attr="alertsin.url" value="https://<host>/api/alerts?LastSeen=2026-09-26%2000:00:00" />
<api:set attr="alertsin.Header:Name#1"  value="Authorization" />
<api:set attr="alertsin.Header:Value#1" value="Bearer [tmp.token]" />
<api:set attr="alertsin.Header:Name#2"  value="client_id" />
<api:set attr="alertsin.Header:Value#2" value="<id>" />

<api:call op="httpGet" in="alertsin" out="raw">
  <api:set attr="row.RawJson" value="[raw.http:content]" />
  <api:push item="row" />
</api:call>

Result: 1 row with the full JSON, starting with {"SyncTimeUtc":"...","Entities":[{"ClientDbId":1198,.... That’s 288 entities, about 2.7 MB.

What this shows

  • Login works and the token is passed correctly. The same token and headers work with httpGet.
  • The endpoint returns valid JSON with a top-level Entities array.
  • The problem is only in jsonproviderGet: it returns 0 rows even with JSONPath=$ and a column that definitely exists.

Current workaround

For now, I’m loading the raw response with httpGet as a single RawJson column. Then I parse it in Incorta with a PySpark Materialized View: from_json with a schema for theEntities array, then explode to get one row per alert. This works, and I get the alerts as a normal table.

I’d much rather have jsonproviderGet return proper rows directly, so I don’t need the extra step or have to load the whole response as one large string.

My questions

  1. Is there a known reason jsonproviderGet would return 0 rows when httpGet with the same request returns the body?
  2. Does jsonproviderGet need the default _input item, instead of a named in="alertsin" item, for the api:info column mappings to apply?
  3. If jsonproviderGet can’t be made to work here, is there a supported way to parse the httpGet response into rows inside the RSD?

Thanks

Hi @stalha.tariq

We are glad to hear you have a workaround. In the meantime regarding the issues you are seeing with jsonproviderGet it should definitely be related to a missing piece in your RSDscript. With that said find your questions addressed below:

  1. I had one of our REST components specialists take a look at the script that you have shared above and they believe the issue is with paging logic not being enabled in your script. Would you be able to add the following line in your script and give it another try?

<api:set attr=“alertsin.EnablePaging” value=“true” />

As for the reason why you keep getting 0 rows, what is likely happening here is that since jsonproviderGet is assuming paging is disabled by default, it is thereby permitting only one request to happen, which is the authentication one. This means the flow is not even reaching to the data request. Switching to httpGet gets around that block, but at the cost of ability to parse the JSON content.

  1. There does not seem to be an issue with the way in=“alertsin” item has been defined. The column mapping should not be stalling unless there is an issue with how the JsonPath in the api info block has been declared or the most important one the data request is not being sent at all.

  2. The httpGet method outputs a content attribute that contains the full response body from the API. I don’t believe we have a built in approach to support that when using only httpGet. You will need to make use of the jsonProviderGet method in order to make that work either way.

If the above does not help you still, please submit a support ticket in the CData Portal and one of our support specialists will further assist.