'How to pass multiple parameters to CURL command when one parameter of JSON type and other is of String type?

I have a JAVA service that accepts JSON input as the first parameter and an optional Boolean pretty printer as the second parameter. If I pass only my mandatory JSON parameter then everything works fine and I am able to get the required out but I am not understanding how to pass my second optional parameter to it.

Following is my Java Service:

@Path("/generate")
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Multi<String> generate(final Map<String, Object> input, @Parameter(description = "Use pretty print for output", example = "?pretty, ?pretty=true, ?pretty=false", schema = @Schema(description = "empty defaults to true",enumeration = {"true", "false"})) @QueryParam("pretty") final String pretty) throws Exception {

}

Following is the Curl command without the 2nd parameter:

curl -X POST 'http://localhost:9001/api/generate' -H 'Content-Type: application/json' -d '{
    "name":"Batman",
    "age":28
}'

I tried to pass the 2nd String parameter something like this:

curl -X POST 'http://localhost:9001/api/generate' -H 'Content-Type: application/json' -d '{
    "name":"Batman",
    "age":28
},true'

But it's not working at all. Can someone please let me know what am I doing wrong and how can I fix the issue?



Solution 1:[1]

I was able to find the fix. Posting here so it can be useful to someone in the future:

The following is working for me:

curl -X POST 'http://localhost:9001/api/generate?pretty=true' -H 'Content-Type: application/json' -d '{
    "name":"Batman",
    "age":28
}'

If you observe I added ?pretty=true to my URL

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 BATMAN_2008