Return id of invalid parameter along with type in INVALID_PARAMETER response


Response:{“errors”:[{“code”:“INVALID_PARAMETER”,“message”:“targeting_value ‘10026996434’ is invalid for targeting type ‘TV_SHOW’”,“attribute”:“targeting_value”}],“request”:{“params”:{“locations”:“96683cc9126741d1”,“tv_shows”:“10004034491,10026996434,10024244366,10002301848,10004773339,10000288432”,“line_item_id”:"",“account_id”:"",“wifi_only”:"",“gender”:“1”}}}

For the above call we’re getting an invalid parameter for one of the ids that we’re trying to add as targeting criteria. When we see an error like this I’d like to be able to relay that error to our clients in a user readable way. To do this right now I’d need to pull the value out of the message string, and then fetch the name of that value from our system or from Twitter. This is doable, but seems fragile as I’d have to rely on the structure of the error message. I noticed however that you’re returning an “attribute” of “targeting_value”. Is there any way that you could add in an “attribute_value” or something similar that includes the list of invalid ids? I understand that sometimes the data isn’t easily accessible when you’re formatting the response, but it would make my life a little easier.


Thanks for that feedback, it’s an interesting idea, and something that we can consider for the future.

It’s unlikely that we’ll modify the error format in the near-term, so you should be able to rely on the format of the returned error message unless you hear something new from us