This code feels worryingly stringily typed, but using URI does not help because the uriPath still has to be constructed with the right uri-encoding.