# Fetch client not serializing body correctly

**URL:** <https://discourse.aurelia.io/t/fetch-client-not-serializing-body-correctly/6531>\
**Category:** Help Requests\
**Created:** [October 31, 2025, 7:43am UTC](https://discourse.aurelia.io/t/fetch-client-not-serializing-body-correctly/6531 "2025-10-31T07:43:34Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![davidsk](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/davidsk/32/930_2.png) [@davidsk](https://discourse.aurelia.io/u/davidsk)\
**Post date:** [October 31, 2025, 7:43am UTC](https://discourse.aurelia.io/t/fetch-client-not-serializing-body-correctly/6531/1 "2025-10-31T07:43:34Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![bigopon](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/bigopon/32/18_2.png) [@bigopon](https://discourse.aurelia.io/u/bigopon)\
**Post date:** [October 31, 2025, 8:20am UTC](https://discourse.aurelia.io/t/fetch-client-not-serializing-body-correctly/6531/2 "2025-10-31T08:20:59Z")

</div>

What do you get witg response.text()?

---

<div class="post-metadata">

**Author:** ![davidsk](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/davidsk/32/930_2.png) [@davidsk](https://discourse.aurelia.io/u/davidsk)\
**Post date:** [October 31, 2025, 8:27am UTC](https://discourse.aurelia.io/t/fetch-client-not-serializing-body-correctly/6531/3 "2025-10-31T08:27:05Z")

</div>

response.text() returns:  
“{“error”:{“code”:“BadRequest”,“message”:“Request body contains invalid JSON.”,“status”:400}}”

---

<div class="post-metadata">

**Author:** ![davidsk](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/davidsk/32/930_2.png) [@davidsk](https://discourse.aurelia.io/u/davidsk)\
**Post date:** [October 31, 2025, 9:00am UTC](https://discourse.aurelia.io/t/fetch-client-not-serializing-body-correctly/6531/4 "2025-10-31T09:00:58Z")

</div>

This is what my request looks like.

```auto
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)

 ![image](https://canada1.discourse-cdn.com/flex027/uploads/aurelia/original/2X/3/389f229e0336fc561b5414cab3e38deca6d3176c.png)

---

<div class="post-metadata">

**Author:** ![bigopon](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/bigopon/32/18_2.png) [@bigopon](https://discourse.aurelia.io/u/bigopon)\
**Post date:** [December 10, 2025, 11:40pm UTC](https://discourse.aurelia.io/t/fetch-client-not-serializing-body-correctly/6531/5 "2025-12-10T23:40:48Z")

</div>

Ahh I missed this. Have you been able to figure out what was wrong @davidsk ?

---

<div class="post-metadata">

**Author:** ![davidsk](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/davidsk/32/930_2.png) [@davidsk](https://discourse.aurelia.io/u/davidsk)\
**Post date:** [December 12, 2025, 8:09am UTC](https://discourse.aurelia.io/t/fetch-client-not-serializing-body-correctly/6531/6 "2025-12-12T08:09:29Z")

</div>

I didn’t, I’m afraid. I found I could achieve the same result using native fetch and configuring a service in an AppTask.

---

<div class="post-metadata">

**Author:** ![bigopon](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/bigopon/32/18_2.png) [@bigopon](https://discourse.aurelia.io/u/bigopon)\
**Post date:** [December 18, 2025, 8:46am UTC](https://discourse.aurelia.io/t/fetch-client-not-serializing-body-correctly/6531/7 "2025-12-18T08:46:30Z")

</div>

we have test with json, and `json` is actually just a JSON.stringify with an if for `undefined` body, i’m not sure why it would have this error. This probably will require some repro on stackblitz if anyone else ever runs into this same issue. Thanks @davidsk
