I haven't succeeded in logging in, and my best guess is that it's related to 'Referer'. When I try this:
- Code: Select all
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(url))
.header("Content-Type", "application/json")
.header("X-CSRFToken", this.token)
.header("Referer", url)
.POST(HttpRequest.BodyPublishers.ofString(json))
.build();
it fails with the error
- Code: Select all
restricted header name: "Referer"
while skipping that line fails with a 403 Forbidden response.
This earlier topic suggests 'Referer' is essential. Comparable code in Python works for me if Referer is specified, but fails if it isn't; GET requests are also working fine from my Java/Groovy code.
Is there anything I'm clearly doing wrong, some other workaround, or should I be giving up on HttpClient for now?
Thanks,
Pete