Unauthorized error for stats endpoint

analytics

#1

Hi
I am getting and 401 Unauthorized error for the stats endpoint. I am able to access the other endpoints.
the following endpoint works
https://ads-api.twitter.com/0/accounts//campaigns
but the following does not
https://ads-api.twitter.com/0/stats/accounts//campaigns?campaign_ids=&start_time=
I am using a .net app and Webrequest to make the call.
Any help is much appreciated.

thanks


#2

twurl request are working fine for the stats endpoint.
Following is the code snippet:

		var resource_url = "https://ads-api.twitter.com/0/stats/accounts/<acctId>/campaigns?campaign_ids=<campId>&start_time=2014-03-19T07%3A00%3A00Z";
		HttpWebRequest request = (HttpWebRequest)WebRequest.Create(resource_url);
        request.Headers.Add("Authorization", authHeader);
        request.Method = "GET";
        request.Accept = "application/json";
        request.ContentType = "application/json";
    try
        {
            response = request.GetResponse();
        }
        catch (WebException ex)
        {
            //handle exception
        }

is this an issue with how the start_time param is formatted?


#3

Hey @BDataimport,

Since making a twurl request seems to work as expected, then it must be that you are missing something in your code.

Have you tried using twurl's -t to get all header information? Have you checked if there are any differences compared to the requests you are making from your code? Do you do any encoding/decoding? What does the actual request look like when being sent out from your code?

If you consider the above questions and dig around a little, I am sure you will figure it out in no time!