Receiving `[invalidJSON]` error when making FusionAuth API calls
-
I am making an API request to FusionAuth to register a user, but FusionAuth is responding with an
[invalidJSON]
error code. The detailed message is:Invalid JSON in the request body. The property
was [unknown]. The error was [Unexpected mapping exception]. The detailed exception was [Unexpected end-of-input in field name\n' +
' at [Source: (org.apache.catalina.connector.CoyoteInputStream); line: 1, column: 84] (through reference chain: io.fusionauth.domain.api.user.RegistrationRequest["user"])].'The same POST request works in the browser, but it does not work when using the Axios HTTP Client.
-
HTTP clients, not just Axios, may impose their own requirements for building a valid request or have their own quirks to deal with.
In this case the error can be resolved by providing a
Content-Length
header with the length of the JSON request data when making the API request via Axios.If you experience issues with a particular HTTP client, it may be helpful to compare the behavior with another client or check whether there are HTTP headers that may be required by the client.
-