OAuth2 Campaign update issue (c#)

174 views
Skip to first unread message

Richard

unread,
Apr 18, 2014, 5:48:40 PM4/18/14
to adwor...@googlegroups.com

I just update from v201309 to v201402 with OAuth2, so far I am able to get access token, refresh token and renew access token.
I am also able to do soap call and retrieve Campaign from Adword API, but when I trying to update Campaign Budget with CampaignOperation. 

I received below error;  The code is working with v201309, the only thing I changed was adding OAuth2 token to the http header when making the SOAP call.

Is this an access problem?

System.Web.Services.Protocols.SoapException: [AuthenticationError.OAUTH_TOKEN_HEADER_INVALID @ ; trigger:'<null>']
   at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
   at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
   at GoogleServices.GoogleCampaign.CampaignService.get(Selector serviceSelector)

Richard

unread,
Apr 18, 2014, 6:00:54 PM4/18/14
to adwor...@googlegroups.com
update: I just tested the active and pause and it worked so the problem is only on budget amount update.

Richard

unread,
Apr 18, 2014, 7:51:17 PM4/18/14
to adwor...@googlegroups.com
In the migration guide, it stats "Budget Optimizer bidding strategy is no longer available. Use the Maximize clicksflexible bid strategy instead."
is this why the soap call is erroring out?

Danial Klimkin

unread,
Apr 21, 2014, 5:26:24 AM4/21/14
to adwor...@googlegroups.com
Hello Richard,


It is unlikely this error will be returned for an invalid bid strategy. Please double-check you use the same credentials for all services.

Also, please make sure your AccessToken is properly refreshed as it is valid for 1 hours only.


-Danial, AdWords API Team.

Richard

unread,
Apr 21, 2014, 9:59:00 AM4/21/14
to adwor...@googlegroups.com
Hi,
I have resolved the authenticate issue but I am still getting the error below, any idea?

System.Web.Services.Protocols.SoapException: [RequiredError.REQUIRED @ operations[0].operand.budget.budgetId] at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall) at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters) at GoogleServices.GoogleCampaign.CampaignService.mutate(CampaignOperation[] operations)

Richard

unread,
Apr 21, 2014, 10:24:38 AM4/21/14
to adwor...@googlegroups.com
Can we still update campaign budget via api, our code below to update budget worked on v201309 but error on v201402

GoogleCampaign.CampaignOperation op = new CampaignOperation();
op.operand = new Campaign {id = campaignID, idSpecified = true};
op.operand.budget = new Budget();
op.operand.budget.amount = new Money();
op.operand.budget.amount.microAmount = Util.FromDecimal(budget);
op.operand.budget.amount.microAmountSpecified = true;
op.@operator = Operator.SET;
op.operatorSpecified = true;

var result = campaignService.mutate(new[] {op});

Anash P. Oommen (AdWords API Team)

unread,
Apr 21, 2014, 2:05:40 PM4/21/14
to adwor...@googlegroups.com
Hi Richard,

The server is complaining about missing budgetId. See the error code snippet, System.Web.Services.Protocols.SoapException: [RequiredError.REQUIRED @ operations[0].operand.budget.budgetId]

Cheers,
Anash P. Oommen,
AdWords API Advisor.

Richard

unread,
Apr 21, 2014, 2:24:02 PM4/21/14
to adwor...@googlegroups.com
Hi Anash, 
We do not have budgetId setup in campaign, is it required to update campaign budget amount? In v201309 we have no problem updating campaign budget without budget id. 
I also checked the campaign selector and it does not return the budget id either.
Thanks,
Richard

Richard

unread,
Apr 22, 2014, 10:48:07 AM4/22/14
to adwor...@googlegroups.com
Any idea? the update campaign budget worked on v201309 without budget id but now failed on v201402, is there any parameter I need to set? thanks!

Anash P. Oommen (AdWords API Team)

unread,
Apr 23, 2014, 11:59:12 AM4/23/14
to adwor...@googlegroups.com
Hi Richard,

You need to

1. Retrieve the budget id using CampaignService.get(). Use BudgetId as the selector field.
2. Set the budget using BudgetService.mutate(). 

My understanding is that you cannot update the budget using CampaignService.mutate any longer.

Cheers,
Anash

Richard

unread,
Apr 28, 2014, 5:04:08 PM4/28/14
to adwor...@googlegroups.com
ok I got it working now. one question, when I use CampaignService.get()  I got the entire list of campaigns. 
Is there a way to select just one campaign based on campaignID?
thanks,
Richard

abhijit chaudhari

unread,
May 14, 2014, 4:38:53 AM5/14/14
to adwor...@googlegroups.com
Hi Richard,

I am facing issues while getting campaigns, My application is ASP.NET MVC and i need to fetch all campaigns but how i can send authtoken while making request. below is sample code which i am using. SoapHeader do not have propert authtoken in v201402 version. can please she some info. we are migrating to v201402 version.

campServiceClient1 = new CampaignServiceInterfaceClient();
                Gateway.Google.CampaignService.SoapHeader RequestHeader = new Gateway.Google.CampaignService.SoapHeader();
                RequestHeader.developerToken = connectionInfo.DeveloperToken.Trim();
                RequestHeader.userAgent = UserAgent;
                //RequestHeader.authToken = authtoken.Trim();
                RequestHeader.clientCustomerId = GoAccountId.ToString();
      
       ///setting selector to download campaigns for the entire account
                CampaignService.Selector selector = new CampaignService.Selector();
                selector.fields = new string[] { "Id", "Name", "Status" };

                CampaignPage cp = new CampaignPage();

                Gateway.Google.CampaignService.SoapResponseHeader res = campServiceClient1.get(RequestHeader, selector, out cp);

Anash P. Oommen (AdWords API Team)

unread,
May 15, 2014, 12:35:51 PM5/15/14
to adwor...@googlegroups.com
Hi Abhijit,

You need to use OAuth2 as authentication mechanism instead of authToken. AdWords API no longer supports ClientLogin as of v201402. From your code snippet, it doesn't look like you are using the AdWords API client library, so you need to use a third party library like http://dotnetopenauth.net/ to add OAuth2 support to your application, and set Authorization: Bearer ACCESS_TOKEN on the outgoing HTTP request header. It's unfortunately not that simple to do that on a Soap service, see http://stackoverflow.com/questions/4661627/how-to-set-http-headers-from-client-class-inherited-from-soaphttpclientprotocol?rq=1 for suggestions on how this may be done.

Just wondering, is there any reason why you chose not to use the AdWords API .NET library?

Cheers,
Anash P. Oommen,
AdWords API Advisor.
Reply all
Reply to author
Forward
0 new messages