2

my code is pretty straightforward:

class App < Grape::API
  resource :pincards do
   post '/' do
   end
  end
end

and i would make a

POST /pincards 

but i end up getting HTTP 405 not allowed. Note that if i changed the "post" to:

get '/' do
end

it will work just fine. so i know my stuff is correct i just don't know why im getting that HTTP 405 on POST.

I also wonder if this sample Grape app shows you how you can do a POST:

https://github.com/dblock/grape-on-rack/

but im unable to follow it.

dB.
  • 4,700
  • 2
  • 46
  • 51
David
  • 4,235
  • 12
  • 44
  • 52

3 Answers3

1

I think you need to have the it like this:

post do
end
0

I would recommend installing the PostMan extension to Google Chrome and giving us some screencaps of some raw JSON POST requests to your API inside PostMan. I recently asked a similar question that was solved by namespacing my API correctly; however, I never would have figured it out without providing some screen caps of my cURL POSTS and some screencaps of the POST request failing in the Network tab of the Dev Tools.

Bottled Smoke
  • 356
  • 1
  • 6
0

It may not solve your problem but for someone else I was getting this error because I was closing the end of resource wrongly.

Mayuresh Srivastava
  • 1,332
  • 17
  • 24