Getting “Illegal character(s) in message header field” using google rest client

Refresh

4 weeks ago

Views

8 time

0

I am having a issue using Google Client where Java is throwing Exception: "java.lang.IllegalArgumentException: Illegal character(s) in message header field: :location"

I have tried url encoding both the key and value but it produces the same result any help would be great!

Code:

GenericUrl url = new GenericUrl(reqUrl);

HttpRequest request = HTTP_TRANSPORT
    .createRequestFactory()
    .buildGetRequest(url);

HttpHeaders headers = new HttpHeaders();
headers.set(":location", "x/y/z");

request.setHeaders(headers);

HttpResponse response = request.execute();

https://developers.google.com/api-client-library/java/google-http-java-client/json

0 answers