Skip to main content

I am using a REST API (CData source) to get source data. Since I need to include a CSR_NONCE value in the header (unique key value), the REST api is set up as a POST. Is it possible to specify that you want to do a POST rather than GET in a CData source?


 

Hi Mirjam

Yes you can do a post statement in the RSD file. Though there normally is not an general way to do it. If you want help to set it up please write to me at support@timextender.com


Hi,

I have moreless the same question but instead for the JSON CData driver. This is the endpoint and result from the Postman client:

 

I only need the fields ‘id’ & ‘name’ so I created the attached RSD file. How to make this file compatible with POST?


I think you should remove some of that sensitive personal data.


Oeps, that blur wasn't stored in the picture. Is there a way to edit this post? The Edit button is not available under the three dots...


@westdorp Edit should be possible on your own post:

 


Unfortunately it is not possible

 


You can only edit for a limited amount of time.


Hi @westdorp 
I changed the image and reuploaded it. Is it acceptable now?

Also I recently made a file doing a Post call to authenticate and get an access_token, which were then used to do the real get call for the data.

<api:script xmlns:api="http://apiscript.com/ns?v1" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<!-- See Column Definitions to specify column behavior and use XPaths to extract column values from JSON. -->
<api:info title="Tasks" desc="Generated schema file." xmlns:other="http://apiscript.com/ns?v1">
<!-- You can modify the name, type, and column size here. -->
<attr name="Id" xs:type="string" readonly="false" other:xPath="/json/Id" />
<attr name="Name" xs:type="string" readonly="false" other:xPath="/json/Name" />
</api:info>

<api:set attr="DataModel" value="DOCUMENT" />
<api:set attr="AuthURI" value="https://api.JSON.cloud/token" />
<api:set attr="DataURI" value="https://api.JSON.cloud/api/v1/tasks/active" />
<api:set attr="EnablePaging" value="true"/>
<api:set attr="elementmapname#" value="access_token"/>
<api:set attr="elementmappath#" value="/json/access_token"/>

<!-- The GET method corresponds to SELECT. Here you can override the default processing of the SELECT statement. The results of processing are pushed to the schema's output. See SELECT Execution for more information. -->
<api:script method="GET">
<api:set attr="temp.access_token" value=""/>
<api:set attr="method" value="POST" />
<api:set attr="URI" value=""AuthURI]"/>
<api:set attr="Header:Name#1" value="Authorization"/>
<api:set attr="Header:Value#1" value="Basic ***********"/>
<api:set attr="JSONPath" value="$"/>

<api:call op="jsonproviderGet" out="auth">
<api:set attr="temp.access_token" value=""auth.access_token]"/>
</api:call>

<api:set attr="method" value="GET" />

<api:set attr="URI" value=""DataURI]"/>
<api:set attr="Header:Name#1" value="Authorization"/>
<api:set attr="Header:Value#1" value="Bearer temp.access_token]"/>
<api:set attr="JSONPath" value="$"/>

<api:call op="jsonproviderGet">
<api:push/>
</api:call>
</api:script>
</api:script>

You don’t have to do the authentication first, of course, so you can remove the bottom part

So it becomes like this.

<api:script xmlns:api="http://apiscript.com/ns?v1" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<!-- See Column Definitions to specify column behavior and use XPaths to extract column values from JSON. -->
<api:info title="ActiveTasks" desc="Generated schema file." xmlns:other="http://apiscript.com/ns?v1">
<!-- You can modify the name, type, and column size here. -->
<attr name="Id" xs:type="string" readonly="false" other:xPath="/json/Id" />
<attr name="Name" xs:type="string" readonly="false" other:xPath="/json/Name" />
</api:info>

<api:set attr="DataModel" value="DOCUMENT" />
<api:set attr="URI" value="https://api.livechatinc.com/v3.5/configuration/action/list_agents" />

<!-- The GET method corresponds to SELECT. Here you can override the default processing of the SELECT statement. The results of processing are pushed to the schema's output. See SELECT Execution for more information. -->
<api:script method="GET">
<api:set attr="method" value="POST" />

<api:set attr="Header:Name#1" value="Authorization"/>
<api:set attr="Header:Value#1" value="Basic ********"/>
<api:set attr="JSONPath" value="$"/>

<api:call op="jsonproviderGet">
<api:push/>
</api:call>
</api:script>
</api:script>

 


Reply