HTTP API DOC ?

Ted Karmel ted.karmel at gmail.com
Wed Jul 7 04:45:42 EDT 2010


Hi Dan,

Thanks for your reply.  The backward slash worked and was exactly what
was needed.

I really appreciate your always helpful suggestions, both here and on
the webmachine mailing list.

Once again thanks,

Ted

On Tue, Jun 29, 2010 at 8:48 PM, Dan Reverri <dan at basho.com> wrote:
> Hi Ted,
> The ibrowse application is expecting the body of the request to be a string,
> binary or function.
> http://wiki.github.com/cmullaparthi/ibrowse/ibrowse-api#type-body
> In your code sample you are passing a list which contains a tuple which
> contains an atom. In Erlang single quotes signify an atom,
> so '{"vvfe":"fegtg"}' is an atom. You should instead pass a string:
> ibrowse:send_req("http://127.0.0.1:8098/riak/test/doc?returnbody=true",[{"Content-Type",
> "application/json"}], put, "{\"vvfe\":\"fegtg\"").
> Let me know if that works for you.
> Thanks,
> Dan
> Daniel Reverri
> Developer Advocate
> Basho Technologies, Inc.
> dan at basho.com
>
>
> On Tue, Jun 29, 2010 at 1:38 PM, Ted Karmel <ted.karmel at gmail.com> wrote:
>>
>> Hi Dan,
>>
>> Thanks for your reply.
>>
>> The REST API link was exactly what I was looking for.
>>
>> By converting the command to HTTP headers, what I meant was seeing all
>> of the request and response headers.  I realize now that  the v
>> parameter does the trick in curl.
>>
>> The curl requests were all successful.  It was the http client request
>> from within erlang that was the problem.  And hence the desire to look
>> at the http headers more closely (as I perhaps misunderstood how to
>> formulate them).
>>
>> Alas, the http client requests still do not work.  I use ibrowse.  I
>> try the following in ibrowse for the put request:
>>
>> 4> ibrowse:send_req("http://127.0.0.1:8091/riak/test/doc?returnbody=true",
>> [{"Content-Type", "application/json"}], put, [{'{"vvfe":"fegtg"}'}]).
>>
>>
>> And I get the following error:
>>
>> {error,{'EXIT',{badarg,[{erlang,list_to_binary,
>>                                 [[{'{"vvfe":"fegtg"}'}]]},
>>                         {ibrowse,ensure_bin,1},
>>                         {ibrowse,do_send_req,7},
>>                         {erl_eval,do_apply,5},
>>                         {shell,exprs,7},
>>                         {shell,eval_exprs,7},
>>                         {shell,eval_loop,3}]}}}
>>
>> Any suggestions?
>>
>>
>>
>>
>> On Tue, Jun 22, 2010 at 10:02 PM, Dan Reverri <dan at basho.com> wrote:
>> > Hi Ted,
>> > A few observations about your original message:
>> > The curl command you provided looks correct, however, there are new line
>> > characters after each header (Content-Type, Riak-X-Vclock). I am not
>> > sure
>> > whether or not those were added by the email client. The presence of new
>> > line characters in the headers would cause the request to fail. The
>> > request
>> > should work without the new line characters:
>> > curl -v -X PUT -d '{"bar":"baz"}' -H "Content-Type: application/json" -H
>> > "X-Riak-Vclock:a85hYGBgzGDKBVIszMk55zKYEhnzWBlKIniO8mUBAA=="
>> > http://127.0.0.1:8091/riak/test/doc?returnbody=true
>> >
>> > I am not sure what you mean by converting the command to HTTP headers.
>> > The
>> > raw request looks as follows:
>> > PUT /riak/test/doc?returnbody=true HTTP/1.1
>> > Content-Type: application/json
>> > X-Riak-Vclock: a85hYGBgzGDKBVIszMk55zKYEhnzWBlKIniO8mUBAA==
>> > {"bar":"baz"}
>> >
>> > Regarding your last attempt, option "c", it's important to note that URL
>> > parameters are not included in the body of the request when processed by
>> > Riak. Riak will store the data included in the body of the request and
>> > ignore unrecognized URL parameters.
>> > Thanks,
>> > Dan
>> > Daniel Reverri
>> > Developer Advocate
>> > Basho Technologies, Inc.
>> > dan at basho.com
>> >
>> >
>> > On Tue, Jun 22, 2010 at 2:27 PM, Dan Reverri <dan at basho.com> wrote:
>> >>
>> >> Hi Ted,
>> >> Documentation for the REST API can be found here:
>> >> https://wiki.basho.com/display/RIAK/REST+API
>> >>
>> >> Regarding the failed requests, can you show us the various requests you
>> >> are making via curl along with the responses?
>> >> Thanks,
>> >> Dan
>> >> Daniel Reverri
>> >> Developer Advocate
>> >> Basho Technologies, Inc.
>> >> dan at basho.com
>> >>
>> >>
>> >> On Tue, Jun 22, 2010 at 1:24 PM, Ted Karmel <ted.karmel at gmail.com>
>> >> wrote:
>> >>>
>> >>> Does Riak have an HTTP API doc ( similar to the CouchDB one found
>> >>> here:  http://wiki.apache.org/couchdb/HTTP_Document_API )?
>> >>>
>> >>> The closest thing I can find is the Riak Fast Track (
>> >>> https://wiki.basho.com/display/RIAK/The+Riak+Fast+Track ).  But that
>> >>> is in curl only rather than explicit HTTP headers.
>> >>>
>> >>> In particular, I have a problem with the PUT request  in the following
>> >>> curl command
>> >>>
>> >>> $ curl -v -X PUT -d '{"bar":"baz"}' -H "Content-Type:
>> >>> application/json" -H "X-Riak-Vclock:
>> >>> a85hYGBgzGDKBVIszMk55zKYEhnzWBlKIniO8mUBAA=="
>> >>> http://127.0.0.1:8091/riak/test/doc?returnbody=true
>> >>>
>> >>> I try to convert the command into HTTP headers but the request fails
>> >>> when the followin is attempted :
>> >>>
>> >>> a)  include {"bar":"baz"} in the body and set the Content-Type header
>> >>> to application/json
>> >>> b)  same as a) but add another Content-Type header value - this time
>> >>> of application/x-www-form-urlencoded   ( inspired by the info on the
>> >>> -d command found in the following curl manual
>> >>> http://curl.haxx.se/docs/manpage.html )
>> >>> c)  same as b) but instead of placing {"bar":"baz"} in the body, add
>> >>> ampersand in the url and bar=baz
>> >>> http://127.0.0.1:8091/riak/test/doc?returnbody=true&bar=baz
>> >>>
>> >>> I tried looking for an equivalent to the Live HTTP Headers extension
>> >>> on Firefox but which would capture activity from curl commands.  Then,
>> >>> I could get a better idea of how to formulate the HTTP headers.
>> >>>
>> >>> Please Help...
>> >>>
>> >>> if there is an HTTP API doc with explicity header request info
>> >>>
>> >>> how to formulate this particular PUT request with the HTTP headers
>> >>>
>> >>> good ubuntu linux utility for capturing http activity even if not from
>> >>> browser application
>> >>>
>> >>> _______________________________________________
>> >>> riak-users mailing list
>> >>> riak-users at lists.basho.com
>> >>> http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
>> >>
>> >
>> >
>
>




More information about the riak-users mailing list