0

I'm using RestAssured to test an API.

I have the following, wow can I test the post method?

{
    "name": "Test",
    "email": "test@email.com",
    "occupation": [{
        "id": 1,
        "feature": {
            "id": 2 
         },
        "company": 7777,
    }]
}

"Occupation" is another table, how can I on both tables? I have tried this:

.body("{\"name\": \"test\", \"email\": \"test@email.com\", \"occupation\": {\"id\": 15, \"feature\": {\"id\": 15}", \"company\": \"7777\"}}")

But the error

"Can not deserialize instance of java.util.ArrayList out of START_OBJECT token"

is shown.

YanetP1988
  • 1,346
  • 3
  • 18
  • 43
gopp
  • 23
  • 6
  • 1
    You asking for help with server code, but not showing us the code, so how did you expect us to help you? – Andreas Sep 20 '17 at 13:52
  • maybe we need some more details.. like your controller for example.. – Teo Sep 20 '17 at 13:53
  • 1
    Possible duplicate of [Can not deserialize instance of java.util.ArrayList out of START\_OBJECT token](https://stackoverflow.com/questions/20837856/can-not-deserialize-instance-of-java-util-arraylist-out-of-start-object-token) – AxelH Sep 20 '17 at 13:53
  • I did not show the code, because I do not have it. I'm just testing the API. – gopp Sep 20 '17 at 13:57

1 Answers1

-1

{\"id\": 15, \"feature\": {\"id\": 15}", \"company\": \"7777\"}}"

Try using JSON array here, too!

f.e.: [{\"id\": 1, \"feature\": {\"id\": 2}", \"company\": \"7777\"}]"

dso
  • 109
  • 10