Consistent 503 error from Twitter Ads API


#1

Hi - I am receiving 503 errors when trying to pull a single day of data. Please see below for additional details.

  • Using the Python Twython sdk for authentication and to make requests: https://twython.readthedocs.io/en/latest/#twython-api-documentation.
  • App Id: 8596508
  • Code for error replication:
    params = {‘end_time’: ‘2019-01-02T00:00:00-08:00’,
    ‘entity’: ‘CAMPAIGN’,
    ‘entity_ids’: [u’bpyhx’, u’bpyhy’, u’bpyhz’, u’bpyi0’, u’bpyi1’, u’bpyi2’, u’bpyi7’, u’bpyi9’, u’bpyia’, u’bpyib’, u’bpyic’, u’bpyie’, u’bpyif’, u’bpyig’, u’bpyih’, u’bpyii’, u’bpyij’, u’bpyik’, u’bpyin’, u’bpyio’],
    ‘granularity’: ‘HOUR’,
    ‘metric_groups’: u’ENGAGEMENT,BILLING,VIDEO,MEDIA,WEB_CONVERSION’,
    ‘placement’: ‘ALL_ON_TWITTER’,
    ‘start_time’: ‘2019-01-01T00:00:00-08:00’}
    from twython import Twython
    from twython import Twython
    twython = Twython(u’REMOVED’, u’REMOVED’, u’REMOVED’, u’REMOVED’)
    twython.get(‘https://ads-api.twitter.com/4/stats/accounts/1la15r’, params=params)

The above command returns: TwythonError: Twitter API returned a 503 (Service Unavailable), Service unavailable due to request timeout; please try the request again later.

Can you please help me resolve this issue? Let me know if you have any other questions.

Thanks!


#2

Hello,

503 errors are temporary and generally resolve themselves within a few minutes. Can you let us know the timestamp for when the issue occurred? Additionally, have you retried the request to see if it succeeds?

Thanks!


#3

Hi - I appreciate the response.

I agree, however I have received the 503 error multiple times when trying to request data.

Most recent timestamps of failures are:
2019-01-04 13:55
2019-01-03 09:30
2019-01-02 08:42

Let me know if you have any other questions.

Thanks!


#4

Hi - Following up on this post. Have you had a chance to look into this issue further?

Thanks!


#5

A quick update here, we’ve identified a couple issues with our analytics pipeline and are currently investigating for a root cause. We’ll update this thread once we know more. Additionally, please let us know if you experience this issue again please let us know along with the following details:

  • The full request/response bodies for the API call
  • The timestamps for when the issue occurred

Thanks!


#6

Hi - Please see the details below for the 503 error received.

params = {‘end_time’: ‘2018-12-03T00:00:00-08:00’,
‘entity’: ‘CAMPAIGN’,
‘entity_ids’: [u’bpyhx’, u’bpyhy’, u’bpyhz’, u’bpyi0’, u’bpyi1’, u’bpyi2’, u’bpyi7’, u’bpyi9’, u’bpyia’, u’bpyib’, u’bpyic’, u’bpyie’, u’bpyif’, u’bpyig’, u’bpyih’, u’bpyii’, u’bpyij’, u’bpyik’, u’bpyin’, u’bpyio’],
‘granularity’: ‘HOUR’,
‘metric_groups’: u’ENGAGEMENT,BILLING,VIDEO,MEDIA,WEB_CONVERSION’,
‘placement’: ‘ALL_ON_TWITTER’,
‘start_time’: ‘2018-12-02T00:00:00-08:00’}
from twython import Twython
from twython import Twython
twython = Twython(u’REMOVED’, u’REMOVED’, uREMOVED’, u’REMOVED’)
twython.get(‘https://ads-api.twitter.com/4/stats/accounts/1la15r’, params=params)

The above command’s response.content = ‘{“errors”:[{“code”:“SERVICE_UNAVAILABLE”,“message”:“Service unavailable due to request timeout; please try the request again later”}],“request”:{“params”:{}}}’
The timestamp of the request was: 2019-01-15T14:46:18.837664


#7

Hi!

We’re looking for an update on this issue. Have you made any progress? Is there a timeline for a fix?


#9

Hi!

Just following up here. Have you made any progress? Is there a timeline for a fix?


#10

Thank you for your patience. We don’t quite have a solution in place as of yet, however we’ve been able to identify a potential bug in our system. Essentially, our backend systems responsible for tracking async requests will timeout occassionally causing a 503 error response.

In the meantime, I’d recommend implementing an exponential back-off and retry strategy to handle these failures. These failures tend to be temporary so retrying these requests would be your best bet.

We’ll update this thread once we’ve got a solution in place.


#11

We’ll try that and we’ll be watching this thread for an update. Thank you for the suggestion!


#12

Exponential backoff was not helpful. The call as described above has not ever completed successfully. No amount of waiting in between calls has resulted in anything other than a 503 response. I’m providing the following information in case it is useful in troubleshooting this issue. Let me know if I can provide anything else.

In order to construct the data set, we are looping through campaigns and the first set always runs successfully. I have included those params below and can confirm we are sending our request to the same URL as listed above.

I went a step further and skipped the first request that has been running successfully to see if the second request that has been failing might have more luck but I received the same 503 response. I did not loop through all of the campaigns but I did go through several and all but the first (listed below) resulted in a 503 error.

‘params’:{
‘placement’:‘ALL_ON_TWITTER’,
‘end_time’:‘2019-01-03T00:00:00-08:00’,
‘metric_groups’:u’ENGAGEMENT,
BILLING,
VIDEO,
MEDIA,
WEB_CONVERSION’,
‘granularity’:‘HOUR’,
‘entity_ids’:[
u’bpyhx’,
u’bpyhy’,
u’bpyhz’,
u’bpyi0’,
u’bpyi1’,
u’bpyi2’,
u’bpyi7’,
u’bpyi9’,
u’bpyia’,
u’bpyib’,
u’bpyic’,
u’bpyie’,
u’bpyif’,
u’bpyig’,
u’bpyih’,
u’bpyii’,
u’bpyij’,
u’bpyik’,
u’bpyin’,
u’bpyio’
],
‘start_time’:‘2019-01-02T00:00:00-08:00’,
‘entity’:‘CAMPAIGN’
}


#13

Hi Tushar!

Do you have a status update on this?