This is a public Forum  publicRSS


    Joel Sunaz
    REST API: how to overwrite instead of add to a...
    Topic posted September 10, 2018 by Joel SunazRookie 
    147 Views, 2 Comments
    REST API: how to overwrite instead of add to a namedIdHierarchy object on PATCH

    I'm trying to update the product and category in an answer record but I need the new value(s) to REPLACE the existing values and not add them as additional product/category which are namedIdHierarchy objects. Below is a sample JSON I pass to a PATCH http request:

    "products" : [{
              "id" : 117
            "id" : 123
    "categories" : [{
          "id" : 154
         "id" : 160

    I tried nulling them out first and then send another request with the new values but this will impact performance as this will now require 2 separate requests.



    • Geetha Amrutha

      Hi Joel,

      I have tried this. And this is how it works for me -
      The product/category values are getting replaced with the new ones instead of them being added as additional product/categories. The old ones are getting nullified automatically when we set new product/category values.

      Not sure why it is not working for you the same way.

      Hope this helps.

      Geetha Amrutha

    • Vlad

      I am getting the same results as Geetha, running version 1.3 of the REST API on product version 18B.