httpquery-stringballerinaballerina-http

Passing Query Parameters in Ballerina HTTP Client


In Ballerina HTTP client, we can send requests using the following syntax:

Album[] albums = check albumClient->/albums;

But if we need to send query parameters with this request like this:

albums?genre=pop

How can we do this with the above syntax?


Solution

  • This can be done similar to how you pass named parameters into a method:

    Album[] albums = check albumClient->/albums(genre = pop);
    

    See the relevant Ballerina By Example here.