Post and curl

32 views
Skip to first unread message

egilchri

unread,
Sep 22, 2008, 10:33:39 PM9/22/08
to Brightkite API
So, there's an example in the API doc:

curl -X POST http://brightkite.com/places/356a192b7913b04c54574d18c28d46e6395428ab/notes
-dnote[body]=supercooltestnote

Assuming I add -u my_user_name:my_pass to the end of this, is this
actually supposed to work? I'm confused by the

-dnote[body]=supercoolltestnote

What I get, from running this in a Unix shell on a Mac, is

csh: curl: no match

Thanks,

Ted Gilchrist

Mike Collins

unread,
Sep 22, 2008, 10:46:26 PM9/22/08
to brightk...@googlegroups.com

The -d option for curl sends the argument as POST data in the request,
so yeah, assuming that your username,password is correct it _should_
work.

mc

egilchri

unread,
Sep 23, 2008, 8:57:52 AM9/23/08
to Brightkite API
Ok, that worked for me. Many thanks! I could have sworn it didn't work
last night.

On Sep 22, 10:46 pm, Mike Collins <collins.m...@gmail.com> wrote:
> The -d option for curl sends the argument as POST data in the request,  
> so yeah, assuming that your username,password is correct it _should_  
> work.
>
> mc
>
> On Sep 22, 2008, at 7:33 PM, egilchri <egilc...@gmail.com> wrote:
>
>
>
> > So, there's an example in the API doc:
>
> > curl -X POSThttp://brightkite.com/places/356a192b7913b04c54574d18c28d46e6395428ab...

egilchri

unread,
Sep 23, 2008, 9:47:16 AM9/23/08
to Brightkite API
Even though I got it to work, I have a lingering question.
Can you explain

note[body]=supercoolltestnote

I understand that the above is POST data. But I guess I've
only run into atomic attributes like the "foo" in foo=bar.
So what is the following, some sort of structured attribute?

note[body]

I want to understand it so I can more readily translate the curl
command into Python.

Thanks,

Ted

Mike Collins

unread,
Sep 23, 2008, 11:55:37 AM9/23/08
to brightk...@googlegroups.com
It doesn't really mean anything special as far as REST or HTTP is
concerned, but since [] characters don't mean anything in urls ( as
opposed to .'s or /'s for example) you can use them to add some
structure to request parameters.

So here's a completely contrived example, but say for instance that
the BK api let you post a note and a photo in one request ( I'm pretty
sure it doesn't, so don't try it, but bear with me for the sake of
argument) and both objects had a 'body' parameter. If you wanted to
do that you could send a request like
note[body]=someNote&photo[body]=somepic.jpg and you could tell pretty
easily which 'body' was which.

Not sure about the python world, but this is pretty common among Rails
apps, since Rails automagically unrolls the request parameters into a
hash-like object and understands the [] structure. No reason you
couldn't do the same thing in python, it's not language specific
although it's nice if the framework you have can do the work for you
so you don't have to write some code to parse the []'s yourself.

mc

egilchri

unread,
Sep 23, 2008, 12:37:50 PM9/23/08
to Brightkite API
Mike,

Thanks for that great explanation. If there was a pithy way to put
it in the doc, it might help folks in the future. Something about how
this POST data will just pass through, and be parsed internally by the
brightkite engine.

Ted

On Sep 23, 11:55 am, "Mike Collins" <collins.m...@gmail.com> wrote:
> It doesn't really mean anything special as far as REST or HTTP is
> concerned, but since [] characters don't mean anything in urls ( as
> opposed to .'s or /'s for example) you can use them to add some
> structure to request parameters.
>
> So here's a completely contrived example, but say for instance that
> the BK api let you post a note and a photo in one request ( I'm pretty
> sure it doesn't, so don't try it, but bear with me for the sake of
> argument) and both objects had a 'body' parameter.  If you wanted to
> do that you could send a request like
> note[body]=someNote&photo[body]=somepic.jpg and you could tell pretty
> easily which 'body' was which.
>
> Not sure about the python world, but this is pretty common among Rails
> apps, since Rails automagically unrolls the request parameters into a
> hash-like object and understands the [] structure.  No reason you
> couldn't do the same thing in python, it's not language specific
> although it's nice if the framework you have can do the work for you
> so you don't have to write some code to parse the []'s yourself.
>
> mc
>

John Barker

unread,
Sep 23, 2008, 12:49:25 PM9/23/08
to brightk...@googlegroups.com
I plan on updating the docs sometime this week.
Reply all
Reply to author
Forward
0 new messages