algoliasearch-client-csharp icon indicating copy to clipboard operation
algoliasearch-client-csharp copied to clipboard

PartialUpdateObject not working when using a JObject payload / the parser doesn't unwrap the objectId correctly

Open jsancho opened this issue 2 years ago • 0 comments

  • Algolia Client Version: 6.12.1
  • Language Version: C# .NET 6.0

Description

Hi,

I've noticed that the PartialUpdateObject was returning without error, but it was failing to actually update the record values on the index.

By debugging the project, I've noticed that the objectId value wasn't a string per se, but the JToken wrapper not fully deserialized. image

Which ultimately lets the code run but doesn't generate the correct url, as the objectId is passed as json in the querystring to the Algolia API.

I've managed to add a fix on a local fork so that I could have a temporary fix to keep my solution running.

The diff below might better explain the issue and how to potentially solve it. https://github.com/algolia/algoliasearch-client-csharp/compare/master...jsancho:algoliasearch-client-csharp:fix-partial-updates-objectid-parser

Could you please review and add a similar fix so that we can use partial updates with json payloads?

Steps To Reproduce

// with payload being a 'JObject'
var index = _searchClient.InitIndex(indexName);
var result = await index.PartialUpdateObjectAsync(payload);

jsancho avatar Jul 18 '22 14:07 jsancho