2

In my web application I need to implement PATCH API endpoint to update/patch some entity. I Know JSON Patch is something I can implement ,but problem here that the data from front end is in From-data format .Is there any way we can implement JsonPatch type process in form data for patch calls??

3
  • What have you tried so far? Mar 3, 2020 at 8:26
  • As of now i am getting complete data request in form -data format like [HttpPatch("myController")] public CustomResponseDTO Update([FromForm] customDataRequestDTO reqDto) but i want to implement json patch type implementation with form data .
    – Zeeshan
    Mar 3, 2020 at 9:55
  • Please, add your actual code to the question Mar 3, 2020 at 10:09

1 Answer 1

0
[HttpPatch("update")]
public Person Patch([FromBody]JsonPatchDocument<Person> personPatch)
{
        personPatch.ApplyTo(_defaultPerson);
        return _defaultPerson;
}

You need to change some configuration below link help to you

https://learn.microsoft.com/en-us/aspnet/core/web-api/jsonpatch?view=aspnetcore-3.1

2
  • I have to use [FromForm] here instead of [FromBody] ,can i use it?
    – Zeeshan
    Mar 4, 2020 at 5:55
  • are you tried [FromBody] instead of [FormForm] just try it. and also refer the link Mar 4, 2020 at 5:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.