Creating database via HTTP with initial data

1 view
Skip to first unread message

conrad....@hotmail.com

unread,
Oct 11, 2014, 8:09:10 AM10/11/14
to sta...@clarkparsia.com
I'm creating a Stardog db using multipart/form-data POST to the HTTP API; this works well until I try to add initial data from a file in the same request. I get back a 500 error but after having looked through the docs, this forum, and using the debugger on stardog.apiary-mock.com to capture my requests I am still clueless as to what I am doing wrong.

Minimal failing example using cURL:

[conradL@slithytove ~]$ curl -i --user admin:admin -H "Content-Type: multipart/form-data" -H "Accept: */*" -X POST -F 'root={"dbname":"testdb","options":{},"files":[{"name":"testfile.ttl"}]}' -F "testfile.ttl=@testfile.ttl;type=text/turtle" http://localhost:5820/admin/databases
HTTP
/1.1 500 There was a fatal error on the server
Content-Length: 0
Server: Stardog/2.2.1/v4

testfile.ttl is a single triple in Turtle format (attached).

There are few things I'm uncertain of here and have tried changing with no joy:
1. Does it matter what I use for the form name for the file part of the request? Currently I'm just using the filename 
2. Does it matter what Content-Type (as specified by the type param in -F) the file part of the request is?
3. Does it matter that I'm not specifying a context in the "files" JSON element? I've also tried "default" and "tag:stardog:api:context:default".

Any guidance appreciated; thanks.

testfile.ttl

Mike Grove

unread,
Oct 13, 2014, 8:53:31 AM10/13/14
to stardog
On Sat, Oct 11, 2014 at 8:09 AM, <conrad....@hotmail.com> wrote:
I'm creating a Stardog db using multipart/form-data POST to the HTTP API; this works well until I try to add initial data from a file in the same request. I get back a 500 error but after having looked through the docs, this forum, and using the debugger on stardog.apiary-mock.com to capture my requests I am still clueless as to what I am doing wrong.

Minimal failing example using cURL:

[conradL@slithytove ~]$ curl -i --user admin:admin -H "Content-Type: multipart/form-data" -H "Accept: */*" -X POST -F 'root={"dbname":"testdb","options":{},"files":[{"name":"testfile.ttl"}]}' -F "testfile.ttl=@testfile.ttl;type=text/turtle" http://localhost:5820/admin/databases
HTTP
/1.1 500 There was a fatal error on the server
Content-Length: 0
Server: Stardog/2.2.1/v4

testfile.ttl is a single triple in Turtle format (attached).

In the "files" list, the property should be "filename", not "name".  I corrected the documentation, sorry about the confusion.
 

There are few things I'm uncertain of here and have tried changing with no joy:
1. Does it matter what I use for the form name for the file part of the request? Currently I'm just using the filename 

It should be the file name, that's the key back to the file list in the root element.
 
2. Does it matter what Content-Type (as specified by the type param in -F) the file part of the request is?

Not really.  We'll use the extension, but it's better if you set the type, that there's not a mismatch.
 
3. Does it matter that I'm not specifying a context in the "files" JSON element? I've also tried "default" and "tag:stardog:api:context:default".

No.  If you don't specify one, the default behavior is that we'll just stick the uploaded data into the default context.

Cheers,

Mike
 

Any guidance appreciated; thanks.

--
-- --
You received this message because you are subscribed to the C&P "Stardog" group.
To post to this group, send email to sta...@clarkparsia.com
To unsubscribe from this group, send email to
stardog+u...@clarkparsia.com
For more options, visit this group at
http://groups.google.com/a/clarkparsia.com/group/stardog?hl=en

Conrad Leonard

unread,
Oct 13, 2014, 9:16:51 PM10/13/14
to sta...@clarkparsia.com
Thanks Michael, for the swift and helpful response on all counts.

Changing the key to "filename" made everything happy.

cheers,
Conrad
Reply all
Reply to author
Forward
0 new messages