POST requests are failing using the @aurelia/fetch-client@2.0.0-beta.23. The response returns with a “Request body contains invalid JSON” message. Inspecting the request in Fiddler shows the body as [object Object]
The exact same request succeeds if I use native fetch. Using the json helper instead of JSON.stringify doesn’t seem to help. I’m using the fetch-client to take advantage of the async interceptor feature.
Any help greatly appreciated.
What do you get witg response.text()?
response.text() returns:
“{“error”:{“code”:“BadRequest”,“message”:“Request body contains invalid JSON.”,“status”:400}}”
This is what my request looks like.
const loginInsertResponse = await this.httpClient.post(
"/data-api/rest/Login",
{
body: json({
"StaticWebAppUserId": clientPrincipal.userId,
"EntraId": aadUser.id
})
});
It seems to make no difference if I send pass just the payload or an object with a body property and the key is the plain object. or serialised using JSON.stringify or the json() helper function.
I’m confident it follows the docs (although intellisense tells me different)