Updating database table using HTTP PATCH verb in Postman

user3623874 picture user3623874 · Mar 21, 2016 · Viewed 7.4k times · Source

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?

Answer

astaykov picture astaykov · Mar 22, 2016

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.