Skip to main content

I'm trying to connect to an InfluxDB source, where a POST request is expected, including flux script in the body to filter data. The output is in CSV format. I have this working in Postman, but how should I configure this in TimeXtender? Anything I try results in the error below, which also means no RSD is generated.

[500] Could not execute the specified command: HTTP protocol error. 405 Method Not Allowed

Hi @dennishanssen 

I would start with exporting the result of the Postman Post call as a json file and then using the rest provider to point at that. You can generate a RSD file on that and then change it to point at the correct location.

If you start with JSON to get a CSV document, you will likely need two data sources to handle it. One REST data source to generate the link to the file and one CSV data source to read it.


@Thomas Lind Thank you for the quick response. I've managed to generate an RSD and I understand having to split into two data sources, but I'm still unsure on how to configure the RSD to make the POST call.


@Thomas Lind I've managed to get it to work using the RSD below. The headers and values are now shifted, but that's probably due to the format of the response and fixable. Thank you!
 

<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="response" desc="Generated schema file." xmlns:other="http://apiscript.com/ns?v1">
<!-- You can modify the name, type, and column size here. -->
<attr name="_field" xs:type="string" readonly="false" other:xPath="/json/_field" />
<attr name="_measurement" xs:type="string" readonly="false" other:xPath="/json/_measurement" />
<attr name="_start" xs:type="string" readonly="false" other:xPath="/json/_start" />
<attr name="_stop" xs:type="string" readonly="false" other:xPath="/json/_stop" />
<attr name="_time" xs:type="string" readonly="false" other:xPath="/json/_time" />
<attr name="_value" xs:type="string" readonly="false" other:xPath="/json/_value" />
<attr name="FIELD1" xs:type="string" readonly="false" other:xPath="/json/FIELD1" />
<attr name="location" xs:type="string" readonly="false" other:xPath="/json/location" />
<attr name="result" xs:type="string" readonly="false" other:xPath="/json/result" />
<attr name="system" xs:type="string" readonly="false" other:xPath="/json/system" />
<attr name="table" xs:type="string" readonly="false" other:xPath="/json/table" />
</api:info>

<api:set attr="DataModel" value="DOCUMENT" />
<api:set attr="URI" value="URI" />

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

<api:script method="GET">
<api:set attr="method" value="POST"/>
<api:set attr="contenttype" value="application/vnd.flux" />
<api:set attr="data">from(bucket: "oogopdekoek") |> range(start: -1h) |> filter(fn: (r) => r._measurement == "temperature")</api:set>
<api:call op="csvproviderGet">
<api:push/>
</api:call>
</api:script>

</api:script>

 


Hi @dennishanssen 

Good your got it to work.


Reply