Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A minimum of 1 items must be provided for categories #136

Open
josephtyler opened this issue Nov 27, 2017 · 3 comments
Open

A minimum of 1 items must be provided for categories #136

josephtyler opened this issue Nov 27, 2017 · 3 comments
Assignees
Labels

Comments

@josephtyler
Copy link
Contributor

When updating a line item, I see a response from the like the following:

{
    "operation_errors": [
        [
            {
                "code": "INVALID_PARAMETER",
                "message": "A minimum of 1 items must be provided for categories",
                "parameter": "categories"
            }
        ]
    ],
    "request": [
        {
            "operation_type": "Update",
            "params": {
                "account_id": "...",
                "bid_amount_local_micro": 290000,
                "bid_type": "MAX",
                "include_sentiment": "ALL",
                "line_item_id": "adagr",
                "name": "...",
                "optimization": "DEFAULT"
            }
        }
    ]
}

Are categories actually required to update a bid on a line item? If this isn't a bug, is there some documentation surrounding this? It appears that categories are not required to be set when working in the web app.

@josephtyler
Copy link
Contributor Author

Looks like this error may be returned when the placement for a line_item is set to PUBLISHER_NETWORK and a category is not set.

@juanshishido
Copy link
Collaborator

juanshishido commented Nov 29, 2017

Thanks, @josephtyler! I was just going to open an issue for this exact thing.

Repro:

>>> from twitter_ads.client import Client
>>> from twitter_ads.campaign import LineItem
>>> ...
>>> client = Client(CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN, ACCESS_TOKEN_SECRET)
>>> account = client.accounts(ACCOUNT_ID)
>>> line_item = LineItem(account).load(account, 'a7bs8')
>>> line_item.name
u'Untitled'
>>> line_item.name = 'add a name'
>>> line_item.save()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/jshishido/.virtualenvs/adsapi/lib/python2.7/site-packages/twitter_ads/resource.py", line 200, in save
    resource, params=self.to_params()).perform()
  File "/Users/jshishido/.virtualenvs/adsapi/lib/python2.7/site-packages/twitter_ads/http.py", line 72, in perform
    raise Error.from_response(response)
twitter_ads.error.BadRequest: <BadRequest object at 0x10f091690 code=400 details=[{u'message': u'A minimum of 1 items must be provided for categories', u'code': u'INVALID_PARAMETER', u'parameter': u'categories'}]>

Looks like this happens because we send all of the line item attributes in the update request and categories is empty:

        response = Request(
            self.account.client, method,
            resource, params=self.to_params()).perform()

resource.py

(Note: this is using twitter-ads 1.2.2, which hasn't yet been updated for v2, which is why we see paused instead of entity_status.)

>>> line_item.to_params()
{  
  'bid_type':u'MAX',
  'name':'add a name',
  'bid_amount_local_micro':10000000,
  'created_at':  u'2017-10-21T15:57:13Z',
  'campaign_id':u'9qpme',
  'bid_unit':u'ENGAGEMENT',
  'updated_at':  u'2017-10-21T16:45:43Z',
  'paused':'true',
  'charge_by':u'ENGAGEMENT',
  'optimization':u'DEFAULT',
  'placements':'TWITTER_TIMELINE',
  'objective':u'TWEET_ENGAGEMENTS',
  'product_type':u'PROMOTED_TWEETS',
  'include_sentiment':u'POSITIVE_ONLY',
  'id':u'a7bs8',
  'categories':''
}

cc: @jbabichjapan, @tushdante

@juanshishido
Copy link
Collaborator

Looks like #119 attempts to address this.

@smaeda-ks smaeda-ks self-assigned this Jul 31, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants