view raw
Suresh Suresh - 6 months ago 39
reST (reStructuredText) Question

REST services PATCH API example

I am trying to call the REST Webservices PATCH API, here is My JSON payload

{ "op":"replace", "path":"/values/Timestamp","value":"2016-10-28T15:25:43.511Z"},
{ "op":"replace", "path":"/values/Flag", "value":true },
{ "op":"replace", "path":"/values/Flow", "value":"Flow A"},
{"op":"replace", "path":"/values/Interests", "value":[ "Sports", "Book Reading" ] }

JSON Value attribute has different values with different data types. and I want to prepare Entity object(Java) and convert it into JSON and call REST end point.
I am not very sure

which is the best suitable data type I can choose for values attribute

I have referred following links but I didn't get enough details

Android REST API using PATCH method

but I didn't get enough details.

any suggestion on this is really appriciated


Got the java object from the client and created another Java class with below properties and set the values

  1. opn - string
  2. path - String
  3. value - Object

added above java objects to array list then used the GSON library to convert it into the array of JSON objects which will be accepted by patch api.

and please note the content type is application/json-patch+json