Search code examples
javajsonspring-bootrestpostman

PostMan - Running collections with data files


I have a Json Request using this body :

{"ecoleId":{{ecoleId}},"niveauScolaireId":{{niveauScolaireId}},"sectionLinguistiqueId":
{{sectionLinguistiqueId}},"sitesSouhaites":{{siteSouhaites}},"taskId":{{task}}}

and this json Data file:

[
{
  "env": "dev",

  "enfantId":75801,
  "exerciceId":2421,

 
  "ecoleId":"1",
  "niveauScolaireId":3,
  "sectionLinguistiqueId":61,
  "sitesSouhaites":[{"id":6},{"id":10}]
}
]

but when running the tests I have this error:

Caused by: com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize value of type `java.lang.Long` from Object value (token `JsonToken.START_OBJECT`)

Solution

  • it seems that the issue might be with the placeholders and these placeholders are not valid JSON syntax and can cause parsing errors! so you need to replace these placeholders with actual values in your JSON request body!

    ok I give you an example but don't forget to replace my digits with the appropriate values you want to use and make sure that the values are of the correct data type like Long for numeric values!!!

    for example:

    {
      "ecoleId": 1,
      "niveauScolaireId": 3,
      "sectionLinguistiqueId": 61,
      "sitesSouhaites": [
        {"id": 6},
        {"id": 10}
      ],
      "taskId": 110110
    }