BatchJobUtilities upload SignatureDoesNotMatch

140 views
Skip to first unread message

rogerccopa

unread,
Apr 25, 2016, 6:16:09 PM4/25/16
to AdWords API Forum, ejay...@merchantadvantage.com, mlam...@merchantadvantage.com
When I try to upload AdGroups in batch it fails with error: The remote server returned an error: (403) Forbidden.
(Just so you know, if I send my AdGroups one at a time (not using BatchJob), it works).
These are the lines of code of how I use the BatchJobService:

BatchJobOperation batchJobOp = new BatchJobOperation();
batchJobOp.@operator = Operator.ADD;
batchJobOp.operand = new BatchJob();

BatchJobService batchJobService = (BatchJobService)myAdWordsUser.GetService(AdWordsService.v201601.BatchJobService);
BatchJob batchJob = batchJobService.mutate(new BatchJobOperation[] {batchJobOp}).value[0];

String uploadUrl = batchJob.uploadUrl.url;

BatchJobUtilities batchJobUploadHelper = new BatchJobUtilities(batchJobService.User);
batchJobUploadHelper.Upload(uploadUrl, myAdGroupOperations.ToArray());  // The ERROR happens on this line.

If it helps, this is the details inside the log xml file:
<?xml version='1.0' encoding='UTF-8'?><Error><Code>SignatureDoesNotMatch</Code><Message>The request signature we calculated does not match the signature you provided. Check your Google secret key and signing method.</Message><StringToSign>PUT

application/xml
1462221844
/batch-job-upload-prod-ebe9b43/73765578/111999231.operations.xml</StringToSign></Error>

Please, if anyone can help me I would appreciate it very much.
Thanks.

Yin Niu

unread,
Apr 26, 2016, 9:34:01 AM4/26/16
to AdWords API Forum, ejay...@merchantadvantage.com, mlam...@merchantadvantage.com
Hi, 

The error is saying the parameters to the method do not match method signature. Please check out this example

Thanks,
Yin, AdWords API Team. 

rogerccopa

unread,
Apr 26, 2016, 10:44:00 AM4/26/16
to AdWords API Forum, ejay...@merchantadvantage.com, mlam...@merchantadvantage.com
Yin Niu, Thank you for your reply.
I reviewed the link you suggested but I see I am doing the same basic steps:

1. Create my AdWords user object.
2. Call BatchJobService.mutate() // this works and it returns an uploadURL.
3. Create BatchJobUtilities object with the same AdWords user.
4. Call BatchJobUtilities.upload(uploadURL, myOperations) // This line fails and returns: SignatureDoesNotMatch

So, based on your response, which parameters am I supposed to provide and how?
I don't create any signature myself, I think the AdWords library does it.

Just in case it helps in any way, this is how I create my AdWords user:
AdWordsUser adWordsUser = new AdWordsUser();
AdWordsAppConfig config = (AdWordsAppConfig)adWordsUser.Config;
config.OAuth2Mode = Google.Api.Ads.Common.Lib.OAuth2Flow.APPLICATION;
config.DeveloperToken = myDeveloperToken;
config.OAuth2ClientId = myClientId;
config.OAuth2ClientSecret = myClientSecret;
config.OAuth2AccessToken = myAccessToken;
config.OAuth2RefreshToken = myRefreshToken;
config.ClientCustomerId = oneOfMyClientsCustomerId;
adWordsUser.OAuthProvider.RefreshAccessToken();

As I mentioned before, sending items to AdWords API one by one works.
I am not sure what else special I need to do to upload items in batch.
And, could you please mention what parameters are included in the "Signature"?

Thanks.

Yin Niu

unread,
Apr 26, 2016, 11:02:53 AM4/26/16
to adwor...@googlegroups.com, ejay...@merchantadvantage.com, mlam...@merchantadvantage.com
Hi, 

Could you please send complete SOAP request and response logs? Just click Reply privately to author in the forum when responding.

Thanks!
Yin, AdWords API Team. 

rogerccopa

unread,
Apr 26, 2016, 12:54:13 PM4/26/16
to AdWords API Forum, ejay...@merchantadvantage.com, mlam...@merchantadvantage.com
Yin Niu,

I found the problem.
In case it can help anyone else having the same issue.

on the following lines of code that I mentioned before:
1. String uploadUrl = batchJob.uploadUrl.url;
2. BatchJobUtilities batchJobUploadHelper = new BatchJobUtilities(batchJobService.User);
3. batchJobUploadHelper.Upload(uploadUrl, myAdGroupOperations.ToArray());  // The ERROR happens on this line.

Before line 3, I need to get a resumable upload url first:
2.1. string resumableUploadUrl = batchJobUploadHelper.GetResumableUploadUrl(uploadUrl); // use here the previous uploadUrl

And then, use resumableUploadUrl to upload:
3. batchJobUploadHelper.Upload(resumableUploadUrl, myAdGroupOperations.ToArray());

That fixed the issue and now it is working.

Thank you Yin Niu for your help.
Reply all
Reply to author
Forward
0 new messages