Ads Analytics Asynchronous API issue

Hi Team,
I was able to get the data when we use synchronous analytics endpoints

App name used : PMReporting
Twitter user account used :

1jwosn
Below are end points used to get the data.
https://ads-api.twitter.com/5/stats/accounts/1jwosn?entity=PROMOTED_TWEET&entity_ids=xxxx&start_time=2019-07-19&end_time=2019-07-25&granularity=TOTAL&metric_groups=ENGAGEMENT&placement=ALL_ON_TWITTER
https://ads-api.twitter.com/5/stats/accounts/1jwosn?entity=PROMOTED_TWEET&entity_ids=xxxx&start_time=2019-07-19&end_time=2019-07-25&granularity=DAY&metric_groups=ENGAGEMENT&placement=ALL_ON_TWITTER
But, we are not receiving any data same query with asynchronous analytics endpoints
https://ads-api.twitter.com/5/stats/jobs/accounts/1jwosn?entity=PROMOTED_TWEET&entity_ids=xxx&start_time=2019-07-19&end_time=2019-07-25&granularity=DAY&metric_groups=ENGAGEMENT&placement=ALL_ON_TWITTER
https://ads-api.twitter.com/5/stats/jobs/accounts/1jwosn?entity=PROMOTED_TWEET&entity_ids=xxxx&start_time=2019-07-19&end_time=2019-07-25&granularity=TOTAL&metric_groups=ENGAGEMENT&placement=ALL_ON_TWITTER
Note: even I tried to increase the data range up to 90 days because due to no segmentation.
Regards

Sudheer Reddy J

Hi @Abhishek ,
Could you please provide us the entity_ids value in the query parameter you masked? I need that to reproduce and investigate it.

Hi,

Entity Id :3ijl92

Hey @Abhishek,
I checked it but I’m seeing data correctly both on Sync and Async endpoint using the exact same request parameters you provided and hence couldn’t reproduce it. Just to confirm, with Async endpoint, you need to download .gz file once your job is done (status: SUCCESS).

Hi,

I am able to get data now. When we download and extract the gz file it is in json fomrat. it it possible to download any other formats rather than Json like csv file.
Thanks and Regards

Hi Team,

Could you please help with below queries

  1. When we download and extract the gz file, it is in json fomrat.is it possible to download any other formats rather than json like (csv, excel etc…) file?
  2. When we Passing Multiple Metric Groups for single request it is giving unauthorized exception.
  3. Multiple gz files are receiving for multiple dates, can we get single gz file for multiple dates ?

Hi @Palvish,

When we request data through GET we are able to receive the data by generating signature in header.

But with same signature generating procedure for POST request we are receiving Unauthorized exception.
Could you please help here
Regards

Sudheer J .

@Abhishek

When we download and extract the gz file, it is in json fomrat.is it possible to download any other formats rather than json like (csv, excel etc…) file?
No. You might want to subscribe to https://github.com/twitterdev/twitter-python-ads-sdk/issues/115 though.
When we request data through GET we are able to receive the data by generating signature in header. But with same signature generating procedure for POST request we are receiving Unauthorized exception.
Since we use OAuth1.0a, a signature is unique per request and you can’t just copy it for other requests like that.

Hi @Palvish,

We are not copying the same signature, we are regenerating signature for POST request like GET Request.

Example

oauthrequestString : POST&https%3A%2F%2Fads-api.twitter.com%2F5%2Fstats%2Fjobs%2Faccounts%2F1jwosn&end_time%3D2019-08-02%26entity%3DPROMOTED_TWEET%26entity_ids%3D3ijl92%26granularity%3DTOTAL%26metric_groups%3DENGAGEMENT%26oauth_consumer_key%3Dxxxx%26oauth_nonce%3DXXXX%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3DXXXX%26oauth_token%3Dxxxx%26oauth_version%3D1.0%26placement%3DALL_ON_TWITTER%26start_time%3D2019-05-04
KeyString : oauth_consumer_secret & oauth_token_secret
Signature : computed Hash value by providing oauthrequestString and KeyString

Below is the header we generated for post request
OAuth oauth_consumer_key=“XXXX”,oauth_nonce=“XXXX”,oauth_signature_method=“HMAC-SHA1”,oauth_timestamp=“XXXX”,oauth_token=“XXXX”,oauth_version=“1.0”,oauth_signature=“qNk0WZvJjvIIPRXlOMzU%2Bei3Gdw%3D”
still we are facing the issue.
any special permissions required for POST request ?

@Abhishek It looks like you’re using Postman as well, right? Are you getting 401 error with your own custom HTTP client? What’s your App ID?
Are you using some kind of OAuth library? or generating signature manually? We highly recommend not generating it manually as there’s a lot of pitfalls.

Hi @Palvish,

We are using HttpWebRequest class to make calls to twitter ads api, We generally will test in post man and once request is ok we will generating request calls based on Postman process.
APP ID : 16485156

Any specific Oauth libary would you suggest ?
Regards

Sudheer

Hi @Palvish,
We used GetAuthorizationHeader(parameters) method from OAuth library to genreate header for post request, but still it has the same issue.
Regards

Sudheer J

@Abhishek Not sure how much I can help you with as I can’t see your actual code. All I can do here is to give you some possible causes of failure.
Just to confirm, you’re able to make a successful request using Postman, but your own code, correct?

Are you encoding your request URL as well? (e.g., encodeURIComponent() in Javascript)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.