I need to add a header ("correlationIdHeader") to a GET Request using Java's HttpUrlConnection. However the server (IBM Http Server - built on Apache) answers with a 400 Error and the following info:
Request header field is missing ':' separator
My code:
HttpURLConnection conn = (HttpURLConnection)url.openConnection();
conn.setRequestProperty("correlationIdHeader", UUID.randomUUID().toString());
conn.setRequestMethod(HttpMethod.GET.name());
conn.setRequestProperty("Accept", contentType);
int responseCode= conn.getResponseCode();
Any idea what could be happening here?
EDIT: it has to do with UUID.randomUUID().toString(). I don't know why but it doesn't like UUID's format. Why?