Skip to main content
Solved

Is it possible to use POST for a REST API?

  • October 29, 2021
  • 8 replies
  • 156 views

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?

 

Best answer by Thomas Lind

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

View original
Did this topic help you find an answer to your question?

8 replies

Thomas Lind
Community Manager
Forum|alt.badge.img+5
  • Community Manager
  • 1015 replies
  • Answer
  • November 1, 2021

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


westdorp
Contributor
  • Contributor
  • 6 replies
  • October 16, 2024

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?


  • Contributor
  • 75 replies
  • October 17, 2024

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


westdorp
Contributor
  • Contributor
  • 6 replies
  • October 17, 2024

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...


devin.tiemens
TimeXtender Xpert
Forum|alt.badge.img+3
  • TimeXtender Xpert
  • 79 replies
  • October 21, 2024

@westdorp Edit should be possible on your own post:

 


westdorp
Contributor
  • Contributor
  • 6 replies
  • October 21, 2024

Unfortunately it is not possible

 


  • Contributor
  • 75 replies
  • October 21, 2024

You can only edit for a limited amount of time.


Thomas Lind
Community Manager
Forum|alt.badge.img+5
  • Community Manager
  • 1015 replies
  • October 23, 2024

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>

 


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings