curl works, but code doesn't
danyaljj opened this issue · comments
Daniel Khashabi commented
When I run the following command, everything works (I see the output):
url --header "Content-Type: application/json" --request POST --data '{"sentence":"I am from China ."}' http://austen.cs.illinois.edu:3283/annotate_elmo
However, I am not sure why none of the following options work:
val out = Http("http://austen.cs.illinois.edu:3283/annotate_elmo").
postForm(Seq("sentence" -> "I am from China .")).header("content-type", "application/json").asParams
or
val out = Http("http://austen.cs.illinois.edu:3283/annotate_elmo").postForm(Seq("sentence" -> "I am from China .")).asParams
The scala code gives me the following error:
[info] Running org.allenai.ari.solvers.squad.ExperimentsApp -t mis-experiments -n 46
[info] HttpResponse(List(),500,Map(Access-Control-Allow-Origin -> Vector(*), Content-Length -> Vector(291), Content-Type -> Vector(text/html), Date -> Vector(Fri, 19 Oct 2018 21:46:12 GMT), Server -> Vector(Werkzeug/0.14.1 Python/3.5.2), Status -> Vector(HTTP/1.0 500 INTERNAL SERVER ERROR)))
Any thoughts?
Jon Hoffman commented
Try this:
Http("http://austen.cs.illinois.edu:3283/annotate_elmo").postData("""{"sentence":"I am from China ."}""").header("content-type", "application/json").asParams