Postman request is incorrect - Bad String

Georgi Michev :

I have this dto for request in my controller

@Data
public class OldTransactionFilterDto {
    List<Long> ids;
    List<Integer> depositConfirmationNumbers;
    List<Long> lenderIds;
    LocalDate transactionDateFrom;
    LocalDate transactionDateTo;
    List<TransactionTypes> types;
    Integer offset;
    Integer limit;
}

The json request I am trying to do in Postman looks like this

{
    "ids" : [1],
    "depositConfirmationNumbers" : [0],
    "lenderIds" : [2],
    "transactionDateFrom" : "2014-01-01",
    "transactionDateTo" : "2019-01-01",
    {"types" : ["Morgage"]},
    "offset" : 1,
    "limit" : 1
}

The TransactionTypes is enum with only one value. In this json Postman says I have error Bad String on my Types value.

Kris :

Well the JSON is invalid

{
    "ids" : [1],
    "depositConfirmationNumbers" : [0],
    "lenderIds" : [2],
    "transactionDateFrom" : "2014-01-01",
    "transactionDateTo" : "2019-01-01",
    {"types" : ["Morgage"]} --->here!,
    "offset" : 1,
    "limit" : 1
}

It must be written as

{
    "ids" : [1],
    "depositConfirmationNumbers" : [0],
    "lenderIds" : [2],
    "transactionDateFrom" : "2014-01-01",
    "transactionDateTo" : "2019-01-01",
    "types" : ["Morgage"],
    "offset" : 1,
    "limit" : 1
}

Make the JSON proper, your error will be gone!

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=299972&siteId=1