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
Sorry for the duplicate post. From: Kendall Shaw <kendall.shaw@workday.com> Date: Sunday, August 20, 2017 at 9:00 PM To: BaseX <basex-talk@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 [1] http://files.basex.org/releases/latest/ On Mon, Aug 21, 2017 at 6:01 AM, Kendall Shaw <kendall.shaw@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 On 8/21/17, 4:22 AM, "Christian Grün" <christian.gruen@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.... " 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 [1] https://urldefense.proofpoint.com/v2/url?u=http-3A__files.basex.org_releases... On Mon, Aug 21, 2017 at 6:01 AM, Kendall Shaw <kendall.shaw@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.... > > > > Kendall > >
participants (2)
-
Christian Grün -
Kendall Shaw