0

I'm getting the following error when trying to get a response using RoboSpice with Jackson mapping do to an incorrect mapping for the error JSON returned

POST request for "https://****/api/register?email=jam@yum.com&first_name=Vege&last_name=Mite&password=qwerty12345&invite_token=oXlTvAvbVR5fiQP6DKCEVQ" 
resulted in 422 (Unprocessable Entity); invoking error handler
E//RequestRunner.java:134īš• 19:01:34.881 Thread-15097 An exception occurred during request network execution :422 Unprocessable Entity

using Curl I get the following correct response:

{"object":"Error","errors":{"email":["has already been taken"]}}

My Model Object for the repose that is failing is as follows, the issue is the "errors" item not mapping correctly but I am not sure what it should be since the variable name "email" can change (i.e. "agent", "vendor" , etc..)

@JsonIgnoreProperties(ignoreUnknown = true)
public class BaseModel {
private String id;
private String email;
private String first_name;
private String last_name;
private String street1;
private String street2;
private String city;
private String state;
private String zipcode;
private String country;
private String phone;
private String create_at;
private String object;
private Map<String, ArrayList<String>> errors;

//Getters and Setters Removed
Dave Newton
  • 158,873
  • 26
  • 254
  • 302
Stuart
  • 73
  • 1
  • 5
  • If your server returns 422 there might be a problem with the request itself and not with the response. Double check the request payload and the content type. – rciovati Feb 22 '14 at 14:59
  • The 422 only returns if the email already exists or another type of error result needs to be returned. If not I get the correct results and app processes the the BaseModel correctly. An example is I can delete this email from the server and the query above will run and return , translated to BaseModel without any issues – Stuart Feb 24 '14 at 15:01
  • Which extension (Sprint, Google Http Client, ect) are you using? – rciovati Feb 26 '14 at 09:14

0 Answers0