add/update tag using the API

MedWMedW Posts: 7 Expensify Newcomer

Greetings:

I'm trying to test how to add a tag using the API but I'm getting a 410 error "'data' attribute for tags is missing or malformed".

I think I have followed the API docs correctly but i'm at a loss of what the issue is. Perhaps some fresh eyes can help. Here is my json payload for the requestJobDescription attribute

  {
    "type": "update",
    "credentials": {
      "partnerUserID": "XXXXX",
      "partnerUserSecret": "XXXXX"
    },
    "inputSettings": {
      "type": "policy",
      "policyID": "XXXXX"
    },
    "tags": {
      "source": "inline",
      "data": {
        "tags": [
          {
            "name": "this is a test tag"
          }
        ]
      }
    }
  }

Any insight would be helpful.

Answers

  • Karisa CaudillKarisa Caudill Posts: 101 Expensify Success Coach

    Hey @MedW !

    It looks like you're missing the "action" portion. Take a look at the Tag Updater example:

    When you run a single section update like just the Tags and not also the Categories, you have to have an action included. Try tossing in the action line and see if that helps you!

  • MedWMedW Posts: 7 Expensify Newcomer

    Karisa, thanks for your suggestion however it did not work.

    Your example uses a CSV file as the data source, I'm trying to use the "inline" option and including the data in a JSON object. The API documentation is unclear if the "action" option can be used interchangeably between "inline" and "file". Below is my updated JSON payload:

       {
        "type": "update",
        "credentials": {
          "partnerUserID": "XXXXX",
          "partnerUserSecret": "XXXXX"
        },
        "inputSettings": {
          "type": "policy",
          "policyID": "XXXXX"
        },
        "tags": {
          "action": "merge",
          "source": "inline",
          "data": {
            "tags": [
              {
                "name": "this is a test tag"
              }
            ]
          }
        }
      }
    

    I'm still getting a 410 error 'data' attribute for tags is missing or malformed and I really don't know why as I feel I'm following your documentation to the letter.

    I know my API calls are working as I'm using the same function to get a list of all tags from the API using the following JSON payload:

    [
      {
        "type": "get",
        "credentials": {
          "partnerUserID": "...",
          "partnerUserSecret": "..."
        },
        "inputSettings": {
          "type": "policy",
          "fields": [
            "tags"
          ],
          "policyIDList": [
            "ABCDEFGFIJSLDLDL",
            "FDERTYUIOPJKJNMS"
          ]
        }
      }
    ]
    

    If you could offer some more insight that would be great...

  • Sasha KlugerSasha Kluger Posts: 3 Expensify Success Coach

    Hi @MedW,

    Your request contains:

    "tags": {
      "source": "inline",
      "data": {
        "tags": [
          {
            "name": "this is a test tag"
          }
        ]
      }
    }
    

    The data attribute should be an array, so could you try changing this to:

    "tags": {
      "data": [
          {
            "name": "Tag",
            "tags": [
                {
                    "name": "this is a test tag"
                }
            ]
          }
      ]
    }
    
Sign In or Register to comment.