Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Updating database table using HTTP PATCH verb in Postman

I am developing an Azure mobile service that contains a table controller with a Patch method:

public Task<User> PatchUser(string id, Delta<User> patch)
{
    return UpdateAsync(id, patch);
}

I am locally hosting my mobile service and want to test how Patch would work. I am using Postman to do that, but I keep getting HTTP Error 400 with the following response:

{ "message": "The HTTP request did not include a valid entity body. Please ensure there is an entity body and an associated Content-Type header present in the request." }

These are the headers I am attaching to HTTP PATCH request: enter image description here

This is request body: enter image description here

I've read on this website that POST requests need to contain bodies like that: [ { "op": "replace", "path": "/email", "value": "[email protected]" } ]

If I provide a request body that you can see in the screenshot below, I still get the same response:

enter image description here

Here is class User that the table controller is based on:

public class User : EntityData
{
    public string Gender { get; set; }
}

How should I properly send a Patch request via Postman?

like image 310
user3623874 Avatar asked Oct 31 '22 07:10

user3623874


1 Answers

You should use your second request but send the 'gender' property with a lowercase g instead of capital G. This is how you define this property in your model, JSON serializer/deserializer is case sensitive by default.

like image 78
astaykov Avatar answered Nov 15 '22 04:11

astaykov