Install the PUT Method on the Rails of XML Queries

if i do this:

curl -X POST -H 'Content-type: application/xml' -d '<person>...</person>' 'http://0.0.0.0:3000/people/12?_method=PUT'

I get "Only requests to receive, post, and delete are allowed." What for? Rails 2.3.2

+3
source share
3 answers

This is actually a malfunction in the latest rails. The solution is to pass an HTTP method to override the header with put. Important: the full name of the header is http-x-http-method-override, but rails adds the http prefix, so you should trim this part.

+3
source

luca , X-Http-Method-Override . _method =, JSON, . curl :

 curl
  -H "X-Http-Method-Override: put"
  -H "Content-Type: application/json"
  -d "{\"user\":{\"email\":\"blah@example.com\"}}"
  www.site.com/users/username.json
+4

, .

-, POST curl, "magic" _method URL-, PUT. , , Rails POST . , .

( config/routes.rb , POST , .

RESTful, , (/people/12), GET, PUT DELETE.

I would try using curl -X PUTand discarding ?_method=PUTfrom your request.

0
source

Source: https://habr.com/ru/post/1714672/


All Articles