com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "response"

1,508 views
Skip to first unread message

Olu Olu

unread,
Oct 26, 2014, 5:06:29 PM10/26/14
to rest-a...@googlegroups.com
Hi,

I am having the above error when I tried to deserialize my response message to a class object. e.g. post(path).as(Myclass.class)
The response(json) message look like:

<response> <head> <per_page></per_page> <page></page> <page_count></page_count> <link rel="next" href="?per_page=50&amp;page=2"/> </head> <content> <orders> <order id="12286f05-35b2-40a0-b712-e64be62389d4"> <status></status> <employee></employee> <order_date></order_date> <store></store> <employee> <parent_order_id/> <fulfillment_centre_id/> </order>

I created 5 fields i.e. id, status, employee, order_date and store(with their setters and getters in the class) even though there are more elements but they didn't return any value, hence reason for me not to create them as fields

Johan Haleby

unread,
Oct 27, 2014, 2:20:01 AM10/27/14
to rest-a...@googlegroups.com
First off all what error message do you get? What does Myclass looks like? Also the response is not JSON, it's XML.

--
You received this message because you are subscribed to the Google Groups "REST assured" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rest-assured...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Olu Olu

unread,
Oct 27, 2014, 7:18:12 AM10/27/14
to rest-a...@googlegroups.com
Hi Johan,

Thanks for your swift reply. well appreciated. the error message I am getting is "com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "response" (class location i.e. com.blah.blah)not marked as ignorable (5 known properties: , "store", "status", "id", "employee", "order_date"]) "
Myclass looks like:
 private String id;
   private String status;
   private String employee;
   private String order_date;
   private String store;
  public void setId(String id){this.id=id;}
  public void setStatus(String status){this.status=status;}
  public void setEmployee(String Employee){this.employee=Employee;}
  public void setOrder_date(String order_date){this.order_date=order_date;}
  public void setStore(String store){this.store=store;}
  public String getId(){return id;}
  public String getStatus(){return status;}
  public String getEmployee(){return employee;}
  public String getOrder_date(){return order_date;}
  public String getStore(){return store;}

Myclass class = post(//path).as(Myclass.class)

If you look at the response xml below, the order element has an attribute id i.e. <order id="12286f05-35b2-40a0-b712-e64be62389d4">
, I think this might be what is causing the error as I have been able to deserialised response that didn't have any attributes with the elements returned. if this is the problem, can you please advice on how to deal with it. Thanks.

Johan Haleby

unread,
Oct 27, 2014, 7:41:52 AM10/27/14
to rest-a...@googlegroups.com
You probably need to annotate the pojo to instruct it to ignore properties, see for example http://stackoverflow.com/questions/4486787/jackson-with-json-unrecognized-field-not-marked-as-ignorable. This has actually little to do with REST Assured, instead it has to do with Jackson (probably).

--
Reply all
Reply to author
Forward
0 new messages