ahmadnassri/httpsnippet

View on GitHub
src/targets/ocaml/cohttp/fixtures/jsonObj-multiline.ml

Summary

Maintainability
Test Coverage
open Cohttp_lwt_unix
open Cohttp
open Lwt

let uri = Uri.of_string "http://mockbin.com/har" in
let headers = Header.add (Header.init ()) "content-type" "application/json" in
let body = Cohttp_lwt_body.of_string "{\n  \"foo\": \"bar\"\n}" in

Client.call ~headers ~body `POST uri
>>= fun (res, body_stream) ->
  (* Do stuff with the result *)