How Do You Add a Tag To An Item?

darryl_ssdarryl_ss Member Posts: 111

Hi,

How do you add a tag to an inventory item please?

I'm trying to update my inventory items with stock, price, cost etc, but the tag does not apply to the item?

  
{
      "ean": "60000005276",
      "defaultCost": "555.9800",
      "tax": "true",
      "itemType": "default",
      "ItemShops": {
        "ItemShop": [
          {
            "itemShopID": "809",
            "qoh": "0",
            "reorderPoint": "0",
            "reorderLevel": "0"
          }
        ]
      },
      "Prices": {
        "ItemPrice": [
          {
            "useTypeID": "1",
            "useType": "Default",
            "amount": "869.9500"
          }
        ]
      },
      "Tag": [
	{
	"name": "Z7"
	}
    ]
 }

6 comments

  • gregaricangregarican Member Posts: 702 
    edited July 2020

    When I have trouble creating or updating a record, I usually pull an existing record to see the JSON structure.

    Like this --> https://api.merchantos.com/API/Account/{AccountId}/Item/{ItemId}.json?load_relations=["TagRelations.Tag"].

    Doing so you would see the structure looks like this:

    "Tags": {

                "@attributes": {

                    "count": "2"

                },

                "tag": [

                    "testtag",

                    "anothertesttag"

                ]

            }

  • darryl_ssdarryl_ss Member Posts: 111
    edited July 2020

    @gregarican

    Hi matey,

    I don't know why this has posted, I deleted this from my draft posts and resolved it earlier. My apologies for wasting your time.

    @Lightspeed I think that the docs could do with updating in reference to tags as they are a little misleading when trying to add a tag to an inventory item.

    Thanks

    Post edited by darryl_ss on
  • darryl_ssdarryl_ss Member Posts: 111

    This post also seems to have posted 4 times?

  • gregaricangregarican Member Posts: 702 

    I recall that issue. You likely need to pass along XML in your request body. See --> https://community.lightspeedhq.com/en/discussion/1484/problem-with-updating-item-tagrelations-tag.

  • darryl_ssdarryl_ss Member Posts: 111

    @gregarican I saw that one.

    My issue was with the format as you posted above.

    The docs show:

     "Tag": [
        {
          "tagID": "4",
          "name": "aqui"
        }
      ]
    

    When it should be the same format as all other array fields on this endpoint:

    "Tags": {
       "Tag": [
         {
          "tagID": "4", // I have not included this in my postBody.
          "name": "aqui"
         }
       ]
    }
    
  • nickmurdocknickmurdock Member Posts: 2
    edited August 28

    darryl_ss, thank you for adding the format in the last post. It's exactly what I needed. I agree that Lightspeed really needs to update its API examples. If you use other SaaS platforms... the examples help so much. See Algolia, Bloomreach.. Bigcommerce, lots of great examples out there on how to do API docs better.

Sign In or Register to comment.