HttpEroor 500 Backend Error and HttpError 403 using DoubleClick Bid Manager API in python

Viewed 262

I need to create and run some queries as well as get the last reports via DoubleClick Bid Manager API in python, after following the example get_last_report.py in Github step by step, I always got an HttpError 500, like:

Traceback (most recent call last):
  File "dbm.py", line 202, in <module>
    main(util.setup(args), args.output_directory, QUERY_ID, args.report_window)
  File "dbm.py", line 154, in main
    response = doubleclick_bid_manager.queries().listqueries().execute()
  File "//anaconda3/lib/python3.7/site-packages/googleapiclient/_helpers.py", line 130, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "//anaconda3/lib/python3.7/site-packages/googleapiclient/http.py", line 856, in execute
    raise HttpError(resp, content, uri=self.uri)
googleapiclient.errors.HttpError: <HttpError 500 when requesting https://www.googleapis.com/doubleclickbidmanager/v1.1/queries?alt=json returned "Backend Error">

Also when I tried to run the example download_line_items.py, I got another error HttpError 403:

Traceback (most recent call last):
  File "download_LI.py", line 81, in <module>
    main(util.setup(args), path, request_body)
  File "download_LI.py", line 57, in main
    handler.write(request.execute()['lineItems'].encode('utf-8'))
  File "//anaconda3/lib/python3.7/site-packages/googleapiclient/_helpers.py", line 130, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "//anaconda3/lib/python3.7/site-packages/googleapiclient/http.py", line 856, in execute
    raise HttpError(resp, content, uri=self.uri)
googleapiclient.errors.HttpError: <HttpError 403 when requesting https://www.googleapis.com/doubleclickbidmanager/v1.1/lineitems/downloadlineitems?alt=json returned "You are not authorized to use DoubleClick Bid Manager API. Please contact dbm-support@google.com.">

I already tried different client secret files, but it didn't work. Any help will be appreciated.

2 Answers

Problem resovled, the account we connecte need access to DBM. Just need to add the google connection account to DBM for all service operation.

This error is very vague, but it always has to be with a tiny error in the request body.

For those in the future:

Check carefully how to create the query body:

https://developers.google.com/bid-manager/v1.1/queries#resource

More than one time I lost miserable hours debugging... and in the end it was:

  • a typo in a key name
  • an extra space like: .... "frequency": "ONE_TIME "

Hope it helps :)

Related