How to write PATCH-requests in Admin Web API Q&A

JSON Patch is a format for describing changes to a JSON document. It can be used to avoid sending a whole document when only a part has changed.

From http://jsonpatch.com/

How do I write a PATCH request in Litium Admin Web API?

(Litium version: 7.4 and later)

First do a GET-Request to see the structure of the entity you want to modify, example for a Variant will look like this:


{

  "baseProductSystemId": "1017fd6b-46c6-4bd3-aba2-279afcca47a3",

  "bundledVariants": [],

  "bundleOfVariants": [

    {

      "quantity": 1,

      "variantSystemId": "2107b3ad-4dab-415b-c41b-08d9349696a7"

    }

  ],

  "fields": {

    "_name": {

      "en-US": "Court Dress – Northern Green",

      "sv-SE": "Court Dress – Northern Green"

    },

    "_url": {

      "en-US": "court-dress-northern-green-l-637598664924201142",

      "sv-SE": "court-dress-northern-green-l-637598664924201142"

    },

    "_seoTitle": {

      "sv-SE": "Court Dress – Northern Green"

    },

    "Color": {

      "*": [

        "Green"

      ]

    },

    "Size": {

      "*": [

        "L"

      ]

    },

    "_images": {

      "*": [

        "cd01dcde-5c47-4b45-8c4b-a80cad57cc9f",

        "dd17df2d-a41a-4029-88f9-10299235a35b",

        "d44aebbd-ce76-4fed-8122-9e5d2da25199",

        "53e5d66d-176d-4fe7-97ce-a31e943e1ffe"

      ]

    }

  },

  "id": "637598664924201142-courtdress-l-001",

  "relationshipLinks": [

    {

      "$type": "Litium.Products.VariantToBaseProductRelationshipLink, Litium.Abstractions",

      "baseProductSystemId": "1017fd6b-46c6-4bd3-aba2-279afcca47a3",

      "relationshipTypeSystemId": "83293c7b-b988-4058-b06d-411f2123ec74"

    }

  ],

  "sortIndex": 9999,

  "systemId": "7cef56a5-303c-4574-98f2-d6dfe6f01ca1",

  "channelLinks": [

    {

      "channelSystemId": "fc44e0dc-af66-4b66-99f8-6973100eb1b0"

    },

    {

      "channelSystemId": "4dfafe7b-d912-4076-95b4-991ead5c35d5"

    }

  ],

  "unitOfMeasurementSystemId": "caa9ffb4-611f-4d29-8a1b-c62a12122c74"

}

To modify this variant we can use the PATCH replace-operation to adjust for example sortindex and name values like this:


[

    {

        "path": "/fields/_name/sv-SE",

        "value": "Court Dress – Northern Green deluxe",

        "op": "replace"

    },

    {

        "path": "/sortIndex",

        "value": 11111,

        "op": "replace"

    }

]

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.