user8930504
user8930504

Reputation: 11

Unexpected character (')' (code 41)) in JMeter request

After I record, I used variable and run. Body data:

{
    "data: [
        {
            "gsVersion":"1.0",
            "stepCode":"${stepCode}",
            "stepName":"${stepName}",
            "familyId":"${familyId}",
            "listGeoEventAddOfStep": [
                {
                    "id":0,
                    "geoEventCode":"${geoEventCode}",
                    "name":"${geoEventName}")},
                    "description":"${geoEventDes}"
                }
            ]
        }
    ]
}

However, it gave the response:

    {
    "timestamp":1514976739620,
    "status":400,
    "error":"Bad Request",
    "exception":"org.springframework.http.converter.HttpMessageNotReadableException",
    "message":"Could not read document: Unexpected character (')' (code 41)): was expecting comma to separate Object entries\n at [Source: java.io.PushbackInputStream@4fa24716; line: 1, column: 175]\n at [Source: java.io.PushbackInputStream@4fa24716; line: 1, column: 150] (through reference chain: com.geopost.controller.requestbody.RequestBodyList[\"data\"]->java.util.ArrayList[0]->com.geopost.dto.GeoStepAddDTO[\"listGeoEventAddOfStep\"]->java.util.ArrayList[0]); nested exception is com.fasterxml.jackson.databind.JsonMappingException: Unexpected character (')' (code 41)): was expecting comma to separate Object entries\n at [Source: java.io.PushbackInputStream@4fa24716; line: 1, column: 175]\n at [Source: java.io.PushbackInputStream@4fa24716; line: 1, column: 150] (through reference chain: com.geopost.controller.requestbody.RequestBodyList[\"data\"]->java.util.ArrayList[0]->com.geopost.dto.GeoStepAddDTO[\"listGeoEventAddOfStep\"]->java.util.ArrayList[0])",
    "path":"/rest/steps"
}

Extracting the exception message for more clarity:

Could not read document: Unexpected character (')' (code 41)):
 was expecting comma to separate Object entries
 at [Source: java.io.PushbackInputStream@4fa24716; line: 1, column: 175]
 at [Source: java.io.PushbackInputStream@4fa24716; line: 1, column: 150]
 (through reference chain: com.geopost.controller.requestbody.RequestBodyList["data"]
   ->java.util.ArrayList[0]->com.geopost.dto.GeoStepAddDTO["listGeoEventAddOfStep"]
   ->java.util.ArrayList[0]);

nested exception is com.fasterxml.jackson.databind.JsonMappingException:
Unexpected character (')' (code 41)):
 was expecting comma to separate Object entries
 at [Source: java.io.PushbackInputStream@4fa24716; line: 1, column: 175]
 at [Source: java.io.PushbackInputStream@4fa24716; line: 1, column: 150]
 (through reference chain: com.geopost.controller.requestbody.RequestBodyList["data"]
   ->java.util.ArrayList[0]
   ->com.geopost.dto.GeoStepAddDTO["listGeoEventAddOfStep"]
   ->java.util.ArrayList[0])

How do I fix this?

Upvotes: 0

Views: 1744

Answers (1)

Ori Marko
Ori Marko

Reputation: 58774

you JSON is invalid, you have for example irrelevant ) sign, a valid JSON can be:

{"data":[{"gsVersion":"1.0","stepCode":"${stepCode}","stepName":"${stepName}","familyId":"${familyId}","listGeoEventAddOfStep":[{"id":0,"geoEventCode":"${geoEventCode}","name":"${geoEventName}"}],"description":"${geoEventDes}"}]}

you can check your json online.

Upvotes: 1

Related Questions