0

If you are updating a variable in a RESTful API, for example person's weight, how should this be laid out?

What I have thought of:

  • PUT /person/1/weight?weight=150
  • PUT /person/1/weight

    {"weight": 150}

  • PUT /person/1/weight

    150

There's been a few answers on this but I don't feel like it's been answered in a clear, solid way.

asked Jun 22, 2015 at 5:32

1 Answer 1

3

Since you are updating just part of the resource you should consider using PATCH HTTP method.

Request format depends on your other API calls. Prefer consistency. If you use JSON elsewhere use JSON. Same goes for XML or whatever language you use.

I suggest using JSON, but I don't know how complex your API is.

Do, I'd do this:

PATCH person/1
Content-Type: application/json
{"weight": 150}
answered Jun 22, 2015 at 5:54
0

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.