Thank you. that's exactly what I need On Fri, Apr 30, 2021 at 6:42 PM Gustaf Neumann <neum...@wu.ac.at> wrote:
> Dear Maksym, > > one can access the content of a PUT/POST request via "ns_getcontent". > Just get the content and parse content e.g. into a dict. > > -gn > > ============================ > if {[ns_conn method] in {PUT POST} > && [ns_set iget [ns_conn headers] Content-Type] eq "application/json" > } { > package req json > > set dict [json::json2dict [ns_getcontent -as_file false]] > ns_return 200 text/plain $dict\n > > } else { > ad_return_complaint 1 "unsupported HTTP method: [ns_conn method]" > } > ============================ > > Test: > curl --header "Content-Type: application/json" --request POST --data > '{"username":"xyz","password":"xyz"}' http://localhost:8100/json-receiver.tcl > > > > > On 30.04.21 19:14, Maksym Zinchenko wrote: > > Hello, maybe it's obvious but I'm a little bit stuck in here. > When I'm doing POST requests to Naviserver with Content-Type: > application/x-www-form-urlencoded, I can use [ns_conn files] [ns_getform] > to access data. > How do I access Content-Type: application/json requests? For example if > I'm sending JSON like that: > { > "action": "list", > "path": "/public_html" > } > How do I get those values? What about Content-Type: application/xml or > text/plain? > > > _______________________________________________ > naviserver-devel mailing list > naviserver-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/naviserver-devel >
_______________________________________________ naviserver-devel mailing list naviserver-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/naviserver-devel