I would like to use Rest Client to query this endpoint: https://landregistry.data.gov.uk/data/ppi/transaction-record.json . If you access the base URI https://landregistry.data.gov.uk/data/ppi/transaction-record , you can see that the endpoint can take several query parameters. For instance, this is a valid url: https://landregistry.data.gov.uk/data/ppi/transaction-record.json?propertyAddress.postcode=M40%200JE
Since I am sure this is not a new use case, I would like to know what is the best approach to create a "mapping" between the endpoint I am going to expose and the query parameters I can use to create the URI to be invoked?
In other words, taking the example above, my service would expose something like:
localhost:8080/transactions?postcode=M400JE
which will invoke:
https://landregistry.data.gov.uk/data/ppi/transaction-record.json?propertyAddress.postcode=M40%200JE
So, postcode should be translated as propertyAddress.postcode. The same with another 20 potential query parameters.
As far as I know, there isn't anything automatic you can do.
Your endpoint would be:
@Path("/transaction")
public class GreetingResource {
@Inject
LandRegistryClient client;
@GET
@Produces(MediaType.APPLICATION_JSON)
public SomeType transaction(@QueryParam("postcode") String postcode) {
return client.transactionRecord(postcode);
}
}
and the REST Client would be:
@Path("/data/ppi")
@RegisterRestClient
public interface CountriesService {
@GET
@Path("transaction-record.json")
@Produces(MediaType.APPLICATION_JSON)
SomeType transactionRecord(@QueryParam("propertyAddress.postcode") String postcode);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.