Request Returns InvalidAuthHeader
Possible Causes:
-
Not using the same secret as configured in Document Platform
-
The values used when calculating token are different from those actually sent, including timeStamp, zOffice-message-nonce, request body
-
The request body serialization results when calculating token and when sending request are inconsistent. For example, if using map to build request body, spring defaults to using jackson to serialize map, then you need to use jackson serialized string to calculate token.
-
Using
org.apache.http.entity.StringEntityto encapsulate request body, without specifyingContent-Type, causing the request body when client and server calculate auth header to be differentStringEntity jsonEntity = new StringEntity(body, ContentType.APPLICATION_JSON); // UTF-8 encoding
StringEntity htmlEntity = new StringEntity(body); // ISO-8859-1 encoding -
Content-Type is not set to application/json, openApi only accepts json format request body.