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