On Sun, 18 Jan 2015 22:03:32 GMT, Drasha wrote:
Hi,
I have a generated rest interface and some functions should accept POST data.
This is a part of my interface:
Json getJson(HTTPServerRequest req, HTTPServerResponse res) { return req.json; } interface IRESTApi { @method(HTTPMethod.POST) @path("/rest/job/:id/configure/") @before!getJson("data") @property Json configureJob(string _id, Json data); }
According to documentation, HTTPServerRequest.json should contain the parsed Json of a JSON request. How does such a JSON request looks like? I tried to send it in many possible forms but the json is always undefined.
I've tried variations of this:
$.ajax({ type: "POST", url: addr, data: JSON.stringify({"hello":"world"}), dataType: "json" })
and this
$.ajax({ type: "POST", url: addr, data: {"hello":"world"}, dataType: "json" })
but to no awail.
Any help is appreciated.
Thanks,
Drasha
It could help to have the request string Vibe.d receive. I think you can get it by setting the loglevel (http://vibed.org/api/vibe.core.log/setLogLevel). If not, you could just fire something like Wireshark.
Beside that, did you change http://vibed.org/api/vibe.http.server/HTTPServerOption ? By default it should just work.