I need to set a param as Not Required in my request.
I tried:
@Get(value = "/list/{username}")
HttpResponse<?> list(String username, @QueryValue(value = "actionCode") String actionCode) {
...
}
When I send the request http://localhost:8080/notification/list/00000000000 the following error is thrown:
{
"message": "Required Parameter [actionCode] not specified",
"path": "/actionCode",
"_links": {
"self": {
"href": "/notification/list/00000000000",
"templated": false
}
}
}
You can define query parameter in Micronaut as optional by
javax.annotation.Nullable
annotation:And here are example calls with their results. Call without
actionCode
:Call with
actionCode
:As you can see there is no error and it works this way in Micronaut version 1 and also in version 2.