Closed patrick-hampton-avalara closed 7 years ago
@patrick-hampton-avalara Can you share how you are adding this operation to your patch document?
Are you creating a JsonPatchDocument
with a list of operations? If so, can you show how you new up this Operation
?
Also, can you try with the dev bits and share if you see the same or a different error? There have been some changes.
@jbagga The JsonPatchDocument document is being created by the Asp.Net Core MVC framework
We're sending the Json from above in the request body:
[{ "op":"add", "path":"/fieldResponseModel/tranlsations/es-ES", "value":{ "language":"es-ES", "Value":"some translated value" } }]
And it's recieved by the Controller with the following signature
public async Task<IActionResult> PatchAsync(int entityId, int id, [FromBody]JsonPatchDocument<FieldResponseModel>> patch)
I then retrieve my existing object by it's id, and call patch.ApplyTo to apply the operations:
var fieldResponseSet = await _fieldResponseService.GetAsync(entityId, id); patch.ApplyTo(fieldResponseSet, ModelState);
I'll try the latest dev bits in a few days and let you know what I see.
@patrick-hampton-avalara I did some investigation.
In 2.0.0 and before, we had the DictionaryAdapter
which threw the error you see here.
In a recent change, DictionaryAdapterOfTU
replaced the old adapter and converts the value to your C# object here. See 0f51c56
So with the latest bits, this scenario should work.
cc @Eilon
@jbagga That's great news. I'll try it out in a few days.
@jbagga can we close this issue then?
Closing this as it was addressed as part of https://github.com/aspnet/JsonPatch/pull/106.
@patrick-hampton-avalara Let us know if you run into an issue!
I have the following model (simplified for example)
I want to perform the following add operation to add a new translation to the Dictionary
[{ "op":"add", "path":"/fieldResponseModel/tranlsations/es-ES", "value":{ "language":"es-ES", "Value":"some translated value" } }]
However, when calling patch.ApplyTo() I get the following exception:
Am I missing something my operation or is this type of add operation not supported?