Question

I'm working on a Lisp API utilizing RESTAS, Hunchentoot and CL-JSON. I have a route defined like this:

(define-route user/register ("/user/register" :method :post)
  (let* ((raw-data (hunchentoot:raw-post-data :force-text t))
     (params (json:decode-json-from-string)))
    (format t "List of parameters: ~a~%" params)
      ))

Now I'm using Postman to send HTTP POST requests with some example JSON data in the request body that looks like this:

{
    "first_name": "John",
    "last_name": "Doe",
    "login": "jdoe",
    "password": "lalala",
    "email": "jdoe@ietf.org",
    "organization": "IETF"
}

The request body clearly gets through, as I'm able to output it to the screen, but the decode-json part leaves me with a 500 server error. I've tried some combinations that seemed reasonable, but I was unable to parse that JSON. Ideally I'd like to parse it to a plist, alist or a hash table. Any help greatly appreciated.

Was it helpful?

Solution

Use (restas:debug-mode-on) for debugging.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top