Try adding

:allowed-methods [:get :post]

to your resource.

You'll want to use "ANY" for all liberator routes, since they manage the responses for incorrect content types internally. If you specify GET or POST, it's up to you to return the proper responses if the methods aren't supported (since Compojure will return nil and try to match further down your list of routes.

gvim <mailto:gvi...@gmail.com>
February 19, 2015 at 8:48 AM


Thanks for spotting that one :). Still not there, though. Now getting simply "Method not allowed".

gvim

Jonathan Barber <mailto:jonathan.bar...@gmail.com>
February 19, 2015 at 5:56 AM
On 18 February 2015 at 22:35, gvim <gvi...@gmail.com <mailto:gvi...@gmail.com>> wrote:

    On 18/02/2015 15:32, Andy- wrote:

        Without having tested it: I think you're "curl -d" format is
        wrong. It's
        not semicolon separated:
        
http://superuser.com/questions/149329/what-is-the-curl-command-line-syntax-to-do-a-post-request

        HTH


    That solved the curl data submission problem but I'm still getting
    errors and suspect the POST defroute isn't correct. 'Trouble all
    the examples of :post submissions in the docs are mixed up with
    other factors so it's difficult to isolate the correct information.


Replace "min" with "minute" in the route (or change "minute" in the curl POST to "min"). Because the field names don't agree, the compojure destructing doesn't match and you end up trying to parseInt nil.

Cheers



    gvim

-- You received this message because you are subscribed to the Google
    Groups "Clojure" group.
    To post to this group, send email to clojure@googlegroups.com
    <mailto:clojure@googlegroups.com>
    Note that posts from new members are moderated - please be patient
    with your first post.
    To unsubscribe from this group, send email to
    clojure+unsubscr...@googlegroups.com
    <mailto:clojure%2bunsubscr...@googlegroups.com>
    For more options, visit this group at
    http://groups.google.com/group/clojure?hl=en
    --- You received this message because you are subscribed to the
    Google Groups "Clojure" group.
    To unsubscribe from this group and stop receiving emails from it,
    send an email to clojure+unsubscr...@googlegroups.com
    <mailto:clojure%2bunsubscr...@googlegroups.com>.
    For more options, visit https://groups.google.com/d/optout.




--
Jonathan Barber <jonathan.bar...@gmail.com <mailto:jonathan.bar...@gmail.com>>
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com <mailto:clojure+unsubscr...@googlegroups.com>.
For more options, visit https://groups.google.com/d/optout.
gvim <mailto:gvi...@gmail.com>
February 18, 2015 at 3:35 PM


That solved the curl data submission problem but I'm still getting errors and suspect the POST defroute isn't correct. 'Trouble all the examples of :post submissions in the docs are mixed up with other factors so it's difficult to isolate the correct information.

gvim

Andy- <mailto:andre.r...@gmail.com>
February 18, 2015 at 8:32 AM
Without having tested it: I think you're "curl -d" format is wrong. It's not semicolon separated:
http://superuser.com/questions/149329/what-is-the-curl-command-line-syntax-to-do-a-post-request

HTH

On Wednesday, February 18, 2015 at 7:09:19 AM UTC-5, g vim wrote:
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com <mailto:clojure+unsubscr...@googlegroups.com>.
For more options, visit https://groups.google.com/d/optout.
gvim <mailto:gvi...@gmail.com>
February 18, 2015 at 5:07 AM
I have a Liberator app which works with this:

(defresource user [day month year hour min region location]
  :available-media-types ["application/json"]
:handle-ok (generate-string (clc/calc day month year hour min 0 (str region "/" location))))

(defroutes app-routes
(GET "/user/:day/:month/:year/:hour/:min/:region/:location" [day month year hour min region location] (user (Integer/parseInt day) (Integer/parseInt month) (Integer/parseInt year) (Integer/parseInt hour) (Integer/parseInt min) region location))

.... but doesn't work with POST:

(defroutes app-routes
  (POST "/user" [day month year hour min region location]
(user (Integer/parseInt day) (Integer/parseInt month) (Integer/parseInt year) (Integer/parseInt hour) (Integer/parseInt min) region location))


Testing with with:

curl -d "day=10;month=8;year=1970;hour=13;minute=45;region=Europe;location=London" http://localhost:3000/user

.... returns an error with the first parameter truncated:

java.lang.NumberFormatException For input string: "14;month=10;year=1960;hour=13;minute=44;region=Europe;location=London"

What am I doing wrong and why is the POST data truncated in the error message?

gvim


--
Sam Ritchie (@sritchie)
Paddleguru Co-Founder
703.863.8561
www.paddleguru.com <http://www.paddleguru.com/>
Twitter <http://twitter.com/paddleguru>// Facebook <http://facebook.com/paddleguru>

--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- You received this message because you are subscribed to the Google Groups "Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to