I received a requestToken that I reuse in a query GET platform/storage/query/v1/query:poll (while state is Running).
It works excepted when the requestToken received contains a “+”.
I got the error “The supplied request-token parameter (xxxxxxxxxxx xxxxxx==) is invalid”.
I try to encode it but I got an error too: The supplied request-token parameter (xxxxxxxxxxx%2Bxxxxxx==) is invalid.
How to fix it?
This usually happens because the request-token is being treated as a URL query parameter, and in query strings a + is often interpreted as a space if it isn’t handled correctly.
So when Dynatrace returns a token containing +, you should make sure the token is passed as a properly encoded query parameter in the query:poll call, and that it is encoded only once.
What to check on the Java side:
Do not build the URL by simple string concatenation
Do not send the raw token directly in the URL
Do not pre-encode it and then let the HTTP client encode it again
The safest approach is to use a URI/query parameter builder and pass the original token value to it, so the client handles encoding correctly.
In practice, the problem is often this:
raw + becomes a space
Or %2B gets encoded again and the API receives the wrong value
So the fix is:
keep the original requestToken
add it as a query parameter with your HTTP client
let the client encode it once
Maybe something like:
URI uri = new URIBuilder(baseUrl + "/platform/storage/query/v1/query:poll")
.addParameter("request-token", requestToken)
.build();
I got the same problem when I was making a n8n automation, not with Java ofc, I suffered a little to got the solution