5

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": "new.email@example.org" } ]

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?

user3623874
  • 520
  • 1
  • 6
  • 25
  • 2
    how about using your second request, but sending `Gender` with capital **G** instead of small **g**. Your model defines `Gender`, not `gender` ? – astaykov Mar 21 '16 at 15:49
  • Thanks, it worked! – user3623874 Mar 21 '16 at 22:30
  • The semantics of application/json as PATCH payload are undefined; you should have a look at RFCs 6902 (https://tools.ietf.org/html/rfc6902) and 7386 (https://tools.ietf.org/html/rfc7386). – Julian Reschke Mar 22 '16 at 07:17

1 Answers1

2

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.

Community
  • 1
  • 1
astaykov
  • 30,768
  • 3
  • 70
  • 86