I am testing posting to ES through HTTP using Elixir.
Here is my IEX shell session. On ES I am getting this: Unhandled exception while processing http request at [http://127.0.0.1:2113/, http://localhost:2113/].
componentText
iex(1)> event = [%{“eventId” => “fbf4a1a1-b4a3-4dfe-a01f-ec52c34e16e4”, “eventType” => “event-type”, “data” => %{“a” => “1”}}]
[%{“data” => %{“a” => “1”}, “eventId” => “fbf4a1a1-b4a3-4dfe-a01f-ec52c34e16e4”,
“eventType” => “event-type”}]
iex(2)> {:ok, json_event} = JSX.encode event
{:ok,
“[{“data”:{“a”:“1”},“eventId”:“fbf4a1a1-b4a3-4dfe-a01f-ec52c34e16e4”,“eventType”:“event-type”}]”}
iex(3)> {:ok, post} = HTTPoison.request(:post, “http://127.0.0.1:2113/streams/newstream”, json_event, [{“Content-Type”, “vnd.eventstore.events+json”}])
{:ok,
%HTTPoison.Response{body: “”,
headers: %{“Access-Control-Allow-Headers” => “Content-Type, X-Requested-With, X-PINGOTHER, Authorization, ES-LongPoll, ES-ExpectedVersion, ES-EventId, ES-EventType, ES-RequiresMaster, ES-HardDelete, ES-ResolveLinkTo, ES-ExpectedVersion”,
"Access-Control-Allow-Methods" => "", "Access-Control-Allow-Origin" => "*",
"Access-Control-Expose-Headers" => "Location, ES-Position",
"Connection" => "close", "Content-Length" => "0", "Content-Type" => "",
"Date" => "Thu, 02 Apr 2015 15:33:39 GMT", "Server" => "Mono-HTTPAPI/1.0"},
status_code: 500}}
``
Any ideas am I missing something?