From e00e6a29410e4ae75abc0480a4d79d07b29008a8 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Wed, 17 Jan 2007 00:46:32 +0000 Subject: Interpret 422 Unprocessable Entity as ResourceInvalid. Closes #7097. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5967 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- activeresource/README | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'activeresource/README') diff --git a/activeresource/README b/activeresource/README index a657e3a471..702ab7efed 100644 --- a/activeresource/README +++ b/activeresource/README @@ -118,7 +118,7 @@ as the id of the ARes object. # when save is called on a new Person object. An empty response is # is expected with a 'Location' header value: # - # Response (200): Location: http://api.people.com:3000/people/2 + # Response (201): Location: http://api.people.com:3000/people/2 # ryan = Person.new(:first => 'Ryan') ryan.new? #=> true @@ -184,7 +184,7 @@ exception. ==== Validation errors Creating and updating resources can lead to validation errors - i.e. 'First name cannot be empty' etc... -These types of errors are denoted in the response by a response code of 400 and the xml representation +These types of errors are denoted in the response by a response code of 422 and the xml representation of the validation errors. The save operation will then fail (with a 'false' return value) and the validation errors can be accessed on the resource in question. @@ -194,7 +194,7 @@ validation errors can be accessed on the resource in question. # # is requested with invalid values, the expected response is: # - # Response (400): + # Response (422): # First cannot be empty # ryan = Person.find(1) @@ -210,13 +210,13 @@ If the underlying Http request for an ARes operation results in an error respons exception will be raised. The following Http response codes will result in these exceptions: 200 - 399: Valid response, no exception - 400: ActiveResource::ResourceInvalid (automatically caught by ARes validation) 404: ActiveResource::ResourceNotFound 409: ActiveResource::ResourceConflict + 422: ActiveResource::ResourceInvalid (rescued by save as validation errors) 401 - 499: ActiveResource::ClientError 500 - 599: ActiveResource::ServerError - + === Authentication Many REST apis will require username/password authentication, usually in the form of @@ -227,4 +227,4 @@ in the Url of the ARes site: self.site = "http://ryan:password@api.people.com:3000/" end -For obvious reasons it is best if such services are available over https. \ No newline at end of file +For obvious reasons it is best if such services are available over https. -- cgit v1.2.3