Twitter Ada Api access error for Stats related endpoint



Our Application ID :- 13481082
Recently we got access for Ads Api and we can access below endpoints.

But while trying any of the Stats related endpoints . Getting Access error.

HttpResponse getstatsdata = twitterAdsInstance.getTwitterAdsClient().get(“”);

Error :-

Exception in thread “main” 401:Authentication credentials ( were missing or incorrect. Ensure that you have set valid consumer key/secret, access token/secret, and the system clock is in sync.
{“errors”:[{“code”:“UNAUTHORIZED_ACCESS”,“message”:“This request is not properly authenticated”}],“request”:{“params”:{}}}

Relevant discussions can be found on the Internet at: or
TwitterException{exceptionCode=[855a0e23-0059c573], statusCode=401, message=This request is not properly authenticated, code=-1, retryAfter=-1, rateLimitStatus=null, version=4.0.4}
at twitter4j.HttpClientImpl.handleRequest(
at twitter4j.HttpClientBase.request(
at twitter4j.HttpClientBase.get(
at twitter4j.TwitterAdsClient.get(
at test.Twitter.TryEndpoint.main(


@ajay_api - Yes it does look like your app was granted access, however you need to go through user authentication for your app ID in order to make API requests. Please follow the getting started on this read page.


Thanks for the reply.
Yes I have done the App authentication part and same reason am able to download Campaigns as well as Promoted tweets. But I can’t download any of the stats. So I was wondering if there is anything still need to be done from backend.

I am able to access below endpoints as well. But none of the stats so far. But in case you want me to check through twurl , I can do that as well. Please let me know the same.


@ajay_api: Please get set up with twurl as this makes debugging easier. Once you’ve got that working, please make the following requests and share the response you’re getting:

$ twurl -H "/1/accounts/awj1s/line_items?count=1"
$ twurl -H "/1/stats/accounts/awj1s/reach/campaigns?campaign_ids=8jw3r&start_time=2016-11-01T07:00:00Z&end_time=2016-11-16T07:00:00Z"
$ twurl -H "/1/stats/accounts/awj1s?entity=CAMPAIGN&entity_ids=8jw3r&start_time=2016-11-01T07:00:00Z&end_time=2016-11-07T07:00:00Z&placement=ALL_ON_TWITTER&granularity=TOTAL&metric_groups=ENGAGEMENT"

There is no reason why you should be able to make one of these and not the other.

Ads API 403 'Unauthorized Access"

I have tried with twurl and it didn’t give any error . Please refer the output here.
But from Java it still gives the error and I can still query campaigns/promoted tweets/line items . Except Stats.

twurl -H “/1/accounts/awj1s/line_items?count=1”




twurl -H "/1/stats/accounts/awj1s/reach/campaigns?campaign_ids=8jw3r&start_time=2016-11-01T07Z"0:00Z&end_time=2016-11-16T07:00:00


twurl -H “/1/stats/accounts/awj1s?entity=CAMPAIGN&entity_ids=8jplacement=ALL_ON_TWITTER&granularity=TOTAL&metric_groups=ENGAGEMENT”



Thanks for confirming, @ajay_api. We can now rule out any access issues. In other words, your app ID has proper access to the Ads API. The issue seems to be with the OAuth implementation. You can visit the OAuth category for additional help.


@ajay_api: As a follow up, please see this post for additional details.


Thanks for the link. I will check the same.