[fluiddb-discuss] json payload

45 views
Skip to first unread message

Tyler Gillies

unread,
Apr 27, 2010, 1:13:51 AM4/27/10
to FluidDB Discuss
can someone please give me an example of a valid json payload, for
example "about" on POST /objects


--
Subscription settings: http://groups.google.com/group/fluiddb-discuss/subscribe?hl=en

Terry Jones

unread,
Apr 27, 2010, 1:24:23 AM4/27/10
to fluiddb...@googlegroups.com
Hi Tyler

> can someone please give me an example of a valid json payload, for
> example "about" on POST /objects

You should probably be producing JSON using a library. What language are
you coding in? Here's an example from Python (2.5.2):

import simplejson as json
data = { 'about' : 'New York' }
json.dumps(data)
>>> '{"about": "New York"}'

See http://www.json.org/ if you want a concise definition of the JSON spec.

BTW, a better place for posting programming questions on FluidDB is
fluidd...@googlegroups.com. But OTOH, we could use some discussion
around here, so it's no problem :-)

Terry

tyler gillies

unread,
Apr 27, 2010, 1:31:06 AM4/27/10
to fluiddb...@googlegroups.com
C:\Users\tyler\Documents\code>curl -v -X POST -d '{"about" : "first attempt"}' "
http://fluiddb.fluidinfo.com/objects" --write-out "%{response_code}" -H "Content
-Type: application/json" -u tjgillies:**********************




* Could not resolve host: :; No data record of requested type
* Closing connection #0
000curl: (6) Could not resolve host: :; No data record of requested type
* About to connect() to fluiddb.fluidinfo.com port 80 (#0)
*   Trying 174.129.210.19... connected
* Connected to fluiddb.fluidinfo.com (174.129.210.19) port 80 (#0)
* Server auth using Basic with user 'tjgillies'
> POST /objects HTTP/1.1
> Authorization: Basic ********************
> User-Agent: curl/7.19.5 (i686-pc-mingw32) libcurl/7.19.5 OpenSSL/0.9.8k zlib/1
.2.3
> Accept: */*
> Content-Type: application/json
> Content-Length: 7
>
< HTTP/1.1 400 Bad Request
< Transfer-Encoding: chunked
< Date: Tue, 27 Apr 2010 05:27:36 GMT
< X-Fluiddb-Error-Class: MalformedPayload
< Content-Type: text/html
< X-Fluiddb-Request-Id: limvetxvzzinlkhz
< Server: TwistedWeb/9.0.0
<
* Connection #0 to host fluiddb.fluidinfo.com left intact
400* Closing connection #0
--
Everyone Loves Tea
http://www.everyonelovestea.com

Terry Jones

unread,
Apr 27, 2010, 1:39:53 AM4/27/10
to fluiddb...@googlegroups.com
Hi Tyler

From your command line, you're sending:

> C:\Users\tyler\Documents\code>curl -v -X POST -d '{"about" : "first attempt"}' "

but in your request you have:

> Content-Length: 7

The response shows

< X-Fluiddb-Error-Class: MalformedPayload

Which makes sense as only 7 bytes of the request will be being passed to
the JSON decoder, which will throw an error.

How is the Content-Length header getting into your request? It looks weird
because curl should know better.

Xavier Noria

unread,
Apr 27, 2010, 2:40:20 AM4/27/10
to fluiddb...@googlegroups.com
On Tue, Apr 27, 2010 at 7:31 AM, tyler gillies <tjgi...@gmail.com> wrote:

> C:\Users\tyler\Documents\code>curl -v -X POST -d '{"about" : "first
> attempt"}' "
> http://fluiddb.fluidinfo.com/objects" --write-out "%{response_code}" -H
> "Content
> -Type: application/json" -u tjgillies:**********************

It's been a while since I touched Windows, but just in case it rings a
bell... does the shell understand those single quotes? Have you
checked the actual payload?

Tristan Seligmann

unread,
Apr 27, 2010, 4:22:28 AM4/27/10
to fluiddb...@googlegroups.com
On Tue, Apr 27, 2010 at 8:40 AM, Xavier Noria <f...@hashref.com> wrote:
> On Tue, Apr 27, 2010 at 7:31 AM, tyler gillies <tjgi...@gmail.com> wrote:
>
>> C:\Users\tyler\Documents\code>curl -v -X POST -d '{"about" : "first
>> attempt"}' "
>> http://fluiddb.fluidinfo.com/objects" --write-out "%{response_code}" -H
>> "Content
>> -Type: application/json" -u tjgillies:**********************
>
> It's been a while since I touched Windows, but just in case it rings a
> bell... does the shell understand those single quotes? Have you
> checked the actual payload?

A careful inspection of the output suggests that it doesn't:

* Could not resolve host: :; No data record of requested type
* Closing connection #0
000curl: (6) Could not resolve host: :; No data record of requested type

ie. it seems to have treated the colon as a separate parameter; the
payload is probably:

'{about

which matches the Content-Length: 7 header. Unfortunately, I'm not
sure exactly what Windows shell incantation is required to quote the
arguments as desired; I think the simplest solution will be to put the
payload in a file, and pass -d @payloadfile to curl.
--
mithrandi, i Ainil en-Balandor, a faer Ambar

Terry Jones

unread,
Apr 27, 2010, 6:17:47 PM4/27/10
to fluiddb...@googlegroups.com
Hi Tristan

> A careful inspection of the output suggests that it doesn't:
>
> * Could not resolve host: :; No data record of requested type Closing
> * connection #0 000curl: (6) Could not resolve host: :; No data record of
> * requested type

Blush. You'd think, after several decades of messing with computers, that I
wouldn't somehow convince myself that the first couple of lines of error
output were probably just some weirdness that could be ignored.... :-)

I guess I did some wishful thinking: saw curl and \Users\tyler in the path
and ignored the backslashes, preferring to imagine that it was Mac OS X.

Anyway, thanks :-)

Terry
Reply all
Reply to author
Forward
0 new messages