I keep getting this error
I know this error means:Reason Summary The login used to generate the access token is not associated with any AdWords account. Common causes The login information provided corresponds to a Google account that does not have AdWords enabled.
Can anyone help me?
-- "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><reportDownloadError><ApiError><type>AuthenticationError.NOT_ADS_USER</type><trigger><null></trigger><fieldPath></fieldPath></ApiError></reportDownloadError>"
I know this error means:
NOT_ADS_USERThe problem is that I am able to use these same credentials in the C# sample asp.net application and get authenticated.
Why would these credentials work in one instance but not this instance?
Here is my code:
using RestSharp;using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;
namespace GoogleAdWordsReportPuller{ class FileGrabber {
string reportDefinition = @"<reportDefinition xmlns=""https://adwords.google.com/api/adwords/cm/v201603""> <selector> <fields>AdGroupName</fields> <fields>Date</fields> <fields>AdGroupStatus</fields> <fields>CampaignName</fields> <fields>Impressions</fields> <fields>Clicks</fields> <fields>Conversions</fields> <fields>Cost</fields> </selector> <reportName>Custom Adgroup Performance Report</reportName> <reportType>ADGROUP_PERFORMANCE_REPORT</reportType> <dateRangeType>YESTERDAY</dateRangeType> <downloadFormat>CSV</downloadFormat></reportDefinition>";
string developerToken = "xxxxxxxxxxxxx"; string clientId = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.apps.googleusercontent.com"; string accessToken = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; // actually a refresh token
string accountId = "585-353-4323"; // client account id
string clientUrl = "https://adwords.google.com/api/adwords/reportdownload/v201603";
public void GetReport() {
//Host: adwords.google.com //User-Agent: curl, gzip //Accept: */* //Accept-Encoding: gzip //Authorization: Bearer [Enter OAuth 2.0 access token here] //developerToken: [Enter developerToken here] //clientCustomerId: [Enter clientCustomerID here] //Content-Length: 784 //Expect: 100-continue //Content-Type: multipart/form-data; boundary=------------------------12d01fae60c7b559
var client = new RestClient(clientUrl); var request = new RestRequest(Method.POST);
// set http headers request.AddHeader("Host", "adwords.google.com"); request.AddHeader("User-Agent", "curl, gzip"); request.AddHeader("Accept", "*/*"); request.AddHeader("Accept-Encoding", "gzip"); request.AddHeader("Authorization", accessToken); // tried request.AddHeader("Authorization", "Bearer " + accessToken); request.AddHeader("developerToken", developerToken); request.AddHeader("clientCustomerId", accountId); request.AddHeader("Content-Length", "784"); //request.AddHeader("Expect", "100-continue"); request.AddHeader("Content-Type", "multipart/form-data; boundary=------------------------12d01fae60c7b559");
//set request parameters request.AddParameter("__rdxml", reportDefinition); // adds to POST or URL querystring based on Method
// execute the request IRestResponse response = client.Execute(request); var content = response.Content; // raw content as string
}
}}
I'm wondering if I need an access token instead because according to the documentation: https://developers.google.com/adwords/api/docs/guides/reporting#complete-example
The http header has a field that says:
POST /api/adwords/reportdownload/v201601 HTTP/1.1 Host: adwords.google.com User-Agent: curl, gzip Accept: */* Accept-Encoding: gzip Authorization: Bearer [Enter OAuth 2.0 access token here] developerToken: [Enter developerToken here] clientCustomerId: [Enter clientCustomerID here] Content-Length: 784 Expect: 100-continue Content-Type: multipart/form-data; boundary=------------------------12d01fae60c7b559
Can anyone help me?
Thanks
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and Google+:
https://googleadsdeveloper.blogspot.com/
https://plus.google.com/+GoogleAdsDevelopers/posts
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
You received this message because you are subscribed to the Google
Groups "AdWords API Forum" group.
To post to this group, send email to adwords-api@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
---
You received this message because you are subscribed to the Google Groups "AdWords API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to adwords-api+unsubscribe@googlegroups.com.
Visit this group at https://groups.google.com/group/adwords-api.
To view this discussion on the web visit https://groups.google.com/d/msgid/adwords-api/72cab096-9d2b-4737-a36a-a2f21564df63%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment