oslofjord / sanity-linq

Strongly-typed .Net Client for Sanity

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Mutations generate invalid request body

roycornelissen opened this issue · comments

Hi, I'm trying to use this client to construct a patch request where I remove an item from an array. This works when using the raw HTTP Mutations API, but I get an error when I try this using the C# client. This is the code:

var mut = client.BeginTransaction<MyDoc>();
mut.PatchById(new Sanity.Linq.Mutations.SanityPatchById<MyDoc>("some-id")
{
    Unset = new[] { "accessControlList[_key==\"some-key-value\"]" }
});
var x = await client.CommitMutationsAsync<MyDoc>(mut);

The response is a Bad Request with the following message: Unknown field "innerBuilder". When capturing the request with Fiddler, I see that it's sending the following request body:

image

I'm using API version v2021-10-21

Update: noticed that any patch request raises this problem. Fixed it by putting JsonIgnore on the InnerBuilder property so that it doesn't end up in the serialized request.

Sounds like a good fix. Can this issue be closed now?