def uri = new UriBuilder('http://someurl.com/api')
I want to append /$contacId/PhoneNumber to the above uri .
How Do I handle this case
def uri = new UriBuilder('http://someurl.com/api')
I want to append /$contacId/PhoneNumber to the above uri .
How Do I handle this case
On
use path method
def uri = new URIBuilder('http://someurl.com/api');
uri.path("/$contacId/PhoneNumber");
On
One-Liner using UriBuilder:
import javax.ws.rs.core.UriBuilder
def contactId = 42
def uri = UriBuilder.fromUri("http://someurl.com/api").path("$contactId/PhoneNumber")
println uri
Output:
http://someurl.com/api/42/PhoneNumber
Test:
Copy-paste the code into https://groovy-playground.appspot.com/