Array of errors in Error Codes & Responses

rest
error-codes

#1

Can anybody show me examples for multiply errors happening in one API request?

I’m thinking that this array can contain only one error at a time and proposing related change to node-twitter library, am I wrong with my assumptions? https://github.com/desmondmorris/node-twitter/pull/107.

here is docs https://dev.twitter.com/ads/basics/response-codes#Error+Response+Structure


#2

I can’t think of every hearing about multiple error messages for a single request. AFAIK Twitter doesn’t do currently do that. I would say it’s safe to assume it will remain with single errors. Worst case is there are more than one error and the first request you see error A, fix it for the second request and then see error B.


#3

@iamstarkov there is potential for multiple errors in the response from the Ads API. The Ads API batch interface (currently a private beta) also returns item-level errors in an ordered array.

To the extent that we can tell you everything wrong with a given failing request in one pass, we always do. You should definitely make sure your code is making no assumptions about the number of errors returned in the response here.

Here’s a real-world example:

"errors": [
    {
      "code": "INVALID",
      "message": "LineItems with different placement types are not allowed inside a campaign : 3222623",
      "attribute": "placement_type"
    },
    {
      "code": "INVALID",
      "message": "Line items with different objectives are not allowed under the same campaign (campaign_id=3222623)",
      "attribute": "objective"
    }
  ],
  "request": {
    "params": {
      "placements": [
        "ALL_ON_TWITTER"
      ],
      "bid_amount_local_micro": 350000,
      "product_type": "PROMOTED_TWEETS",
      "objective": "TWEET_ENGAGEMENTS",
      "account_id": "5gvk9h",
      "include_sentiment": "ALL",
      "campaign_id": "1x2lb"
    }
  }
}