I try to access an open data web service which gives me traffic infos. Documentation says that requests have to be GET and need to contain Accept: applica
The Accept header tells the server what your client wants in the response. The Content-Type header tells the server what the client sends in the request. So the two are not the same.
If the server only accepts application/json, you must send a request that specifies the request content:
Content-Type: application/json
That's why your edited code works.
Edit
In your first code you use WebTarget.request(MediaType... acceptedResponseTypes). The parameters of this method
define the accepted response media types.
You are using Innvocation.Builder.accept(MediaType... mediaTypes) on the result of this method call. But accept() adds no new header, it is unnecessary in your first code.
You never specify the content type of your request. Since the server expects a Content-Type header, it responds with 415.