RESTXQ %input:csv annotation
The example produces an error saying it can’t convert string to document node:
declare %rest:path("/store.csv") %rest:POST("{$csv}") %input:csv("header=true,encoding=CP1252") function page:store-csv($csv as document-node()) { "Number of rows: " || count($csv/csv/record) };
I can just change the function signature and parse the string with csv:parse, but is the example missing a detail (or am I missing a detail)?
I used this to store CSV data in the default format.
curl –XPOST –H’Content-Type: text/csv’ –data @some.csv http://example.com/basex/store.csvKendall
Sorry for the duplicate post.
Quoted text · Kendall Shaw · 16 lines
From: Kendall Shaw <kendall.shaw at workday.com> Date: Sunday, August 20, 2017 at 9:00 PM To: BaseX <basex-talk at mailman.uni-konstanz.de> Subject: RESTXQ %input:csv annotation The example produces an error saying it can’t convert string to document node: declare %rest:path("/store.csv") %rest:POST("{$csv}") %input:csv("header=true,encoding=CP1252") function page:store-csv($csv as document-node()) { "Number of rows: " || count($csv/csv/record) }; I can just change the function signature and parse the string with csv:parse, but is the example missing a detail (or am I missing a detail)? I used this to store CSV data in the default format. curl –XPOST –H’Content-Type: text/csv’ –data @some.csv http://example.com/basex/store.csv Kendall
Hi Kendall,
In BaseX 8.6.5, only "text/comma-separated-values" is detected as CSV media type, so the following should work:
curl -XPOST -H"Content-Type: text/comma-separated-values" -data @some.csv "http://example.com/basex/store.csv"
I noticed that "text/csv" is much more common, and other types such as "application/csv" as used as well. With [1], all media types with sub type "csv" or "comma-separated-values" will now be accepted as CSV input.
Hope this helps, Christian
Quoted text · Kendall Shaw · 39 lines
On Mon, Aug 21, 2017 at 6:01 AM, Kendall Shaw <kendall.shaw at workday.com> wrote: > The example produces an error saying it can’t convert string to document > node: > > > > declare > > %rest:path("/store.csv") > > %rest:POST("{$csv}") > > %input:csv("header=true,encoding=CP1252") > > function page:store-csv($csv as document-node()) { > > "Number of rows: " || count($csv/csv/record) > > }; > > > > I can just change the function signature and parse the string with > csv:parse, but is the example missing a detail (or am I missing a detail)? > > > > I used this to store CSV data in the default format. > > > > curl –XPOST –H’Content-Type: text/csv’ –data @some.csv > http://example.com/basex/store.csv > > > > Kendall > >
Thank you, that worked. And I’ll note that text/csv will be handled when I update BaseX.
Kendall
Quoted text · Christian Grün · 1 line
On 8/21/17, 4:22 AM, "Christian Grün" <christian.gruen at gmail.com> wrote:
Hi Kendall,
In BaseX 8.6.5, only "text/comma-separated-values" is detected as CSV media type, so the following should work:
curl -XPOST -H"Content-Type: text/comma-separated-values" -data @some.csv "https://urldefense.proofpoint.com/v2/url?u=http-3A__example.com_basex_store.csv&d=DwIFaQ&c=DS6PUFBBr_KiLo7Sjt3ljp5jaW5k2i9ijVXllEdOozc&r=JgwnBEpN1c-DDmq-Up2QMq9rrGyfWK0KtSpT7dxRglA&m=rNboQKVnWnXp-YmOjjhaMZd8_9BoqGIjpH3YIUKgxBE&s=_HNnJt3O3gQfHwOJD_A5KK3FemeBoPP_FPvYbn_3ZCY&e= "
I noticed that "text/csv" is much more common, and other types such as "application/csv" as used as well. With [1], all media types with sub type "csv" or "comma-separated-values" will now be accepted as CSV input.
Hope this helps, Christian
Quoted text · Kendall Shaw · 39 lines
On Mon, Aug 21, 2017 at 6:01 AM, Kendall Shaw <kendall.shaw at workday.com> wrote: > The example produces an error saying it can’t convert string to document > node: > > > > declare > > %rest:path("/store.csv") > > %rest:POST("{$csv}") > > %input:csv("header=true,encoding=CP1252") > > function page:store-csv($csv as document-node()) { > > "Number of rows: " || count($csv/csv/record) > > }; > > > > I can just change the function signature and parse the string with > csv:parse, but is the example missing a detail (or am I missing a detail)? > > > > I used this to store CSV data in the default format. > > > > curl –XPOST –H’Content-Type: text/csv’ –data @some.csv > https://urldefense.proofpoint.com/v2/url?u=http-3A__example.com_basex_store.csv&d=DwIFaQ&c=DS6PUFBBr_KiLo7Sjt3ljp5jaW5k2i9ijVXllEdOozc&r=JgwnBEpN1c-DDmq-Up2QMq9rrGyfWK0KtSpT7dxRglA&m=rNboQKVnWnXp-YmOjjhaMZd8_9BoqGIjpH3YIUKgxBE&s=_HNnJt3O3gQfHwOJD_A5KK3FemeBoPP_FPvYbn_3ZCY&e= > > > > Kendall > >
Written for BaseX 8.6. BaseX may have changed since: please check the current documentation.