Reputation: 357
I am trying to write some code to retrieve my account status from the ripple API (https://ripple.com/wiki/JSON_Messages). The code I am currently using:
#require "netclient";;
open Http_client.Convenience;;
let account_info =
[
("command","account_info");
("account","my_account_key")
]
;;
let response = http_post_message "http://s1.ripple.com:51234" account_info;;
I am sending the request to http://s1.ripple.com:51234 and I am receiving a Bad Request error. Note: I have tried both method and command as parameters as well as the http_post and http_post_message methods.
# response#status;;
- : Http_client.status = `Client_error
# response#response_status;;
- : Nethttp.http_status = `Bad_request
I must be doing something fundamentally wrong with the way I am requesting the data but I do not have enough experience with this subject matter to know where I am going wrong. I thought that maybe I should use the Http_client.post_raw method, however my toplevel cannot recognize this method. I am not sure how to proceed to correct my errors.
# Http_client.post_raw;;
Error: Unbound value Http_client.post_raw
Thanks in advance.
Upvotes: 0
Views: 224
Reputation: 605
There's probably something wrong with your server :
$ curl -v http://s1.ripple.com:51234/
* About to connect() to s1.ripple.com port 51234 (#0)
* Trying 54.200.86.207...
* Adding handle: conn: 0x7f92a1808c00
* Adding handle: send: 0
* Adding handle: recv: 0
* Curl_addHandleToPipeline: length: 1
* - Conn 0 (0x7f92a1808c00) send_pipe: 1, recv_pipe: 0
* Connected to s1.ripple.com (54.200.86.207) port 51234 (#0)
> GET / HTTP/1.1
> User-Agent: curl/7.32.0
> Host: s1.ripple.com:51234
> Accept: */*
>
* Empty reply from server
* Connection #0 to host s1.ripple.com left intact
curl: (52) Empty reply from server
I used OcamlNet a lot and if I can advise you : test your url with curl in a terminal before.
Upvotes: 1
Reputation: 6697
When using HTTP API first and foremost test the API with curl command-line utility. Once you get an expected response - implement the code to send the same request with same headers. Check with curl -v
and the debugging facilities of your http library.
Upvotes: 3