5 Replies Latest reply on Sep 16, 2019 5:49 AM by Sai Prasad

    REST API to classify an item

    Vishesh R Simha Seasoned Veteran

      Hi,

       

      I am trying to classify an item through REST API.

       

      Please let me know what is the mistake in my code. Below are the details

       

      REST API URL :

      http://<servername>:1512/rest/V1.0/list/Article/ArticleStructureGroupMap

       

      Body:

       

      {

      "columns": [

      {"identifier": "ArticleStructureGroupMap.StructureProxy"},

      {"identifier": "ArticleStructureGroupMap.StructureGroupProxy"}

      ],

      "rows": [

      {

      "object":

      {"id": "578843@1"},

      "values": ["SECURITY SYSTEM","ITEM_ENRICHMENT_ONGOING_WMDS"]

      }

      ]

      }

       

      Error:

       

      {

          "counters": {

              "errors": 3,

              "warnings": 0,

              "createdObjects": 0,

              "updatedObjects": 1,

              "objectsWithErrors": 1,

              "objectsWithWarnings": 0

          },

          "entries": [

              {

                  "row": 0,

                  "objectType": "Item",

                  "object": {

                      "id": "578843@1",

                      "label": "7NY78",

                      "entityId": 1000

                  },

                  "severity": "ERROR",

                  "category": "DATATYPE",

                  "propertyLabel": "Structure group",

                  "message": "Value 'ITEM_ENRICHMENT_ONGOING_WMDS' could not be converted into target type. Check logs for details.",

                  "logDate": "2019-09-11",

                  "logTime": "09:22:28"

              },

              {

                  "row": 0,

                  "objectType": "Item",

                  "object": {

                      "id": "578843@1",

                      "label": "7NY78",

                      "entityId": 1000

                  },

                  "severity": "ERROR",

                  "category": "RANGE",

                  "propertyLabel": "",

                  "message": "Structure: The field value does not correspond to an active value from the bullet 'Structure systems'. ( 9000[|] )",

                  "logDate": "2019-09-11",

                  "logTime": "09:22:28"

              },

              {

                  "row": 0,

                  "objectType": "Item",

                  "object": {

                      "id": "578843@1",

                      "label": "7NY78",

                      "entityId": 1000

                  },

                  "severity": "ERROR",

                  "category": "CONSISTENCY",

                  "propertyLabel": "",

                  "message": "Cannot set articleDisplayOrder because mapping to structure group is missing.",

                  "logDate": "2019-09-11",

                  "logTime": "09:22:28"

              }

          ],

          "objects": [

              {

                  "row": 0,

                  "object": {

                      "id": "578843@1",

                      "label": "7NY78",

                      "entityId": 1000

                  },

                  "status": [

                      "UPDATED",

                      "ERROR"

                  ]

              }

          ]

      }

        • 1. Re: REST API to classify an item
          Sai Prasad Guru

          Hi Vishesh,

           

          URL: http://localhost:1512/rest/V1.0/list/Article/ArticleStructureMap

           

          BODY:

          {

          "columns": [

          {"identifier": "ArticleStructureMap.ManualMap"}

          ],

          "rows": [

          {

          "object":

          {"id": "7@1"},

            "qualification" : { "structureId" : "TestStructure" },

          "values": ["Node1"]

          }

          ]

          }

           

          Where the 7@1 is the ArticleID@catalogID from the database or else you can use like SupplierAID@Catalog For example

          'TestItem'@'MASTER'

           

          RESPONSE:

          {

           

             "counters": {

             "errors": 0,

             "warnings": 0,

             "createdObjects": 0,

             "updatedObjects": 1,

             "objectsWithErrors": 0,

             "objectsWithWarnings": 0

            },

             "entries": [],

             "objects": [

            {

             "row": 0,

             "object": {

             "id": "7@1",

             "label": "Test_Sai_Item",

             "entityId": 1000

            },

             "status": [

             "UPDATED"

            ]

            }

            ]

          }

           

          Please revert us if that doesn't work for you.

           

          Thank you

          Sai Prasad

          • 2. Re: REST API to classify an item
            Vishesh R Simha Seasoned Veteran

            Thank You Sai Prasad for this answer.

             

            In our case we have two structure systems.

             

            1. All Items

            2. Security Systems.

             

            Item when imported is already classified into one of the structure group in All Items. Now using REST API we are trying to assign it to a structure group in Security Systems. Hence when REST API is executed first time, item is assigned to a structure group of Security System with error.

             

            http://p360udevapp:1512/rest/V1.0/list/Article/ArticleStructureMap

             

            {

            "columns": [

            {"identifier": "ArticleStructureMap.ManualMap"}

            ],

            "rows": [

            {

            "object":

            {"id": "578843@1"},

            "qualification" : {  "structureId" : "SECURITY SYSTEM" },

            "values": ["ITEM_ENRICHMENT_ONGOING_WMDS"]

            }

            ]

            }

             

            Result

             

            {

                "counters": {

                    "errors": 1,

                    "warnings": 0,

                    "createdObjects": 0,

                    "updatedObjects": 1,

                    "objectsWithErrors": 1,

                    "objectsWithWarnings": 0

                },

                "entries": [

                    {

                        "row": 0,

                        "objectType": "Item",

                        "object": {

                            "id": "578843@1",

                            "label": "7NY78",

                            "entityId": 1000

                        },

                        "severity": "ERROR",

                        "category": "UNIQUENESS",

                        "propertyLabel": "",

                        "message": "Duplicate check: A corresponding entry of this data type already exists: Structure assignments.",

                        "logDate": "2019-09-11",

                        "logTime": "22:03:58"

                    }

                ],

                "objects": [

                    {

                        "row": 0,

                        "object": {

                            "id": "578843@1",

                            "label": "7NY78",

                            "entityId": 1000

                        },

                        "status": [

                            "UPDATED",

                            "ERROR"

                        ]

                    }

                ]

            }

             

            Second Time when this is executed for different structure group of Security system, item is assigned to a structure group of Security System without any error.

             

            http://p360udevapp:1512/rest/V1.0/list/Article/ArticleStructureMap

             

            {

            "columns": [

            {"identifier": "ArticleStructureMap.ManualMap"}

            ],

            "rows": [

            {

            "object":

            {"id": "578843@1"},

            "qualification" : {  "structureId" : "SECURITY SYSTEM" },

            "values": ["ITEM_ENRICHMENT_ONGOING_NWMDS"]

            }

            ]

            }

             

             

            Result

             

            {

                "counters": {

                    "errors": 0,

                    "warnings": 0,

                    "createdObjects": 0,

                    "updatedObjects": 1,

                    "objectsWithErrors": 0,

                    "objectsWithWarnings": 0

                },

                "entries": [],

                "objects": [

                    {

                        "row": 0,

                        "object": {

                            "id": "578843@1",

                            "label": "7NY78",

                            "entityId": 1000

                        },

                        "status": [

                            "UPDATED"

                        ]

                    }

                ]

            }

            • 3. Re: REST API to classify an item
              Sai Prasad Guru

              Hi Vishesh,

               

              Already assignment has done? The message Duplicate check: A corresponding entry of this data type already exists: Structure assignments." showing. Could you please check that?

               

              Thank you

              Sai Prasad

              • 4. Re: REST API to classify an item
                Vishesh R Simha Seasoned Veteran

                Hi Sai Prasad,

                 

                Even though error was thrown structure group assignment happened. I was able to embed this code in Active VOS BPEL, and the process was executed without any error. Thank you

                • 5. Re: REST API to classify an item
                  Sai Prasad Guru

                  Hi Vishesh,

                   

                  Got it. Thanks for reverting us that it worked.

                   

                  Thank you

                  Sai Prasad