Skip to main content

Request Returns InvalidAuthHeader

Possible Causes:

  1. Not using the same secret as configured in Document Platform

  2. The values used when calculating token are different from those actually sent, including timeStamp, zOffice-message-nonce, request body

  3. 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.

  4. Using org.apache.http.entity.StringEntity to encapsulate request body, without specifying Content-Type, causing the request body when client and server calculate auth header to be different

    StringEntity jsonEntity = new StringEntity(body, ContentType.APPLICATION_JSON); // UTF-8 encoding
    StringEntity htmlEntity = new StringEntity(body); // ISO-8859-1 encoding
  5. Content-Type is not set to application/json, openApi only accepts json format request body.