Jersey 2 .25.1 Rest client with java 8 query parameters with special characters such as $ -
i having problems while creating rest client using jersey 2.25.1. trying data https://data.sfgov.org can run special queries using $where, $limit , $offset. below tried , did not work. failing 400 bad request - thought send parameters raw list, not sure on how that. should use different rest client or how can resolve this?
i tried netflix feign seems slow.
private static string url = "https://data.sfgov.org/resource/bbb8- hzi6.json"; /** * @param args */ public static void main(string[] args) { string day = formatdate("eeee"); string time24 = formatdate("hh"); system.out.println("day " + day + " time24 = " + time24); client client = clientbuilder.newclient(); webtarget webtarget = client.target(url); string whereparams = "start24<='" + time24+ "'+and+end24>='" + time24 + "'"; webtarget = webtarget.queryparam("$order", "applicant") .queryparam("$where", uricomponent.encode(whereparams, uricomponent.type.fragment)); system.out.println(webtarget.geturi().tostring()); invocation.builder invocationbuilder = webtarget .request(mediatype.text_plain_type); list<foodtruck> foodtrucklist = invocationbuilder.get(generictype<list<foodtruck>>(){}); for(foodtruck fd : foodtrucklist) { system.out.println(fd.getapplicant()); } }
Comments
Post a Comment