How to send Object which contains an arraylist in the postman

Viewed 677

I am doing a project in springboot rest API. My controller class look like below,

@RequestMapping(value = "/artdimfil", method = RequestMethod.POST, consumes = "application/json", produces = "application/json")
    @ResponseBody
    public boolean saveArticleDimFilter(@RequestBody ArtDimFil artDimFil)

I want to send the below payload in the postman,

{
    "id": "b30d1486-04c8-4acc-8d14-8604c81accab",
    "docIdentifier": {
        "recType": "ABC",
        "accesslist": [
         {
        "userid": "xyz@abc.com",
        "role": "abc",
        "status": "Active",
        "actiondate": "2020-07-03T17:59:34.600+0000",
        "name": "XYZ",
      }]
    }
}

But it is giving the error saying

[org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Cannot deserialize instance of `com.ibm.epm.next.model.Accesslist` out of START_ARRAY token; nested exception is com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize instance of `com.ibm.epm.next.model.Accesslist` out of START_ARRAY token.

Please suggest me what to do.

2 Answers

It's trying to deserialize to "AccessList" - but I think it's not using YOUR "AccessList", because the error says: Cannot deserialize instance of com.ibm.epm.next.model.Accesslist

I suggest you rename your class, or make sure you have the correct import statement. You should import your own "AccessList" class.

I think you should delete comma after "XYZ"

   {
    "userid": "xyz@abc.com",
    "role": "abc",
    "status": "Active",
    "actiondate": "2020-07-03T17:59:34.600+0000",
    "name": "XYZ",
  }

also will be good show how looks docIdentifier class and show what class inside accesslist

Related