Reputation: 25842
OCamlnet 3 has Http_client.Convenience.http_post
.
Its API is like this:
val http_post : string -> (string * string) list -> string
Does a "POST" request with the given URL and returns the response body. The list contains the parameters send with the POST request.
My question is::
where should I supply the header and data body for the post request
?
Upvotes: 2
Views: 99
Reputation: 10299
AFAIR you can not provide custom header in Convenience method. However, you can always use the pipeline API:
let _ =
let call = new Http_client.post
"http://localhost:8080"
[("param", "value")]
in
call#set_req_header "User-Agent" "Foozilla 1.0";
call#set_req_header "Myheader" "foo";
let pipeline = new Http_client.pipeline in
pipeline#add call;
pipeline#run ();
Upvotes: 2