batchjobService exmaple code without client library

64 views
Skip to first unread message

Javeed Syed

unread,
Jan 20, 2016, 2:22:09 PM1/20/16
to AdWords API Forum
Hi, 

Am trying to replace MutateJobService to BatchJobService 201509 without Java client Library
i used SOAP request for MutationJobService for previous versions. Now am trying to do the same with BatchJobService. It is not accepting when i upload the campaigns to uploadUrl. It seems like am missing something.

I am getting exception in response BatchJobProcessingError.FILE_FORMAT_ERROR. This does not explain the exactly what is the issue.
Here is the xml request which i have used to upload

<?xml version='1.0' encoding='UTF-8'?><ns1:mutate xmlns:ns1='https://adwords.google.com/api/adwords/cm/v201509'><operations xsi:type='ns1:CampaignOperation' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'><operator xsi:type='ns1:Operator'>SET</operator><operand xsi:type='ns1:Campaign'><id>*********</id><name>Ping</name><status>ENABLED</status><startDate>2015-12-02</startDate><endDate>2016-12-31</endDate><budget xsi:type='ns1:Budget'><budgetId>*********</budgetId><period>DAILY</period><amount xsi:type='ns1:Budget'><ComparableValue.Type>Money</ComparableValue.Type><microAmount>30000000</microAmount></amount><deliveryMethod>STANDARD</deliveryMethod></budget><adServingOptimizationStatus>OPTIMIZE</adServingOptimizationStatus><advertisingChannelType>SEARCH</advertisingChannelType><networkSetting xsi:type='ns1:NeyworkSetting'><targetGoogleSearch>true<argetGoogleSearch><targetContentNetwork>false<argetContentNetwork></networkSetting><biddingStrategyConfiguration xsi:type='ns1:BiddingStrategyConfiguration'><biddingStrategyType>MANUAL_CPC</biddingStrategyType><biddingScheme xsi:type='ManualCpcBiddingScheme'><enhancedCpcEnabled>false</enhancedCpcEnabled></biddingScheme></biddingStrategyConfiguration><trackingUrlTemplate>"someting"<rackingUrlTemplate></operand></operations></mutate>


Here is the response for the uploadedURL



<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v20="https://adwords.google.com/api/adwords/cm/v201509" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><SOAP-ENV:Header><v20:RequestHeader><v20:developerToken>************</v20:developerToken><v20:clientCustomerId>**********</v20:clientCustomerId></v20:RequestHeader></SOAP-ENV:Header><SOAP-ENV:Body><v20:get><v20:selector><v20:fields>Id</v20:fields><v20:fields>Status</v20:fields><v20:fields>ProgressStats</v20:fields><v20:fields>DownloadUrl</v20:fields><v20:predicates><v20:field>Id</v20:field><v20:operator>EQUALS</v20:operator><v20:values>1138360</v20:values></v20:predicates></v20:selector></v20:get></SOAP-ENV:Body></SOAP-ENV:Envelope><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Header><ResponseHeader xmlns="https://adwords.google.com/api/adwords/cm/v201509"><requestId>000529c5ec49fbe90ac478881f0efbf9</requestId><serviceName>BatchJobService</serviceName><methodName>get</methodName><operations>1</operations><responseTime>135</responseTime></ResponseHeader></soap:Header><soap:Body><getResponse xmlns="https://adwords.google.com/api/adwords/cm/v201509"><rval><totalNumEntries>1</totalNumEntries><Page.Type>BatchJobPage</Page.Type><entries><id>1138360</id><status>CANCELED</status><progressStats><numOperationsExecuted>0</numOperationsExecuted><numOperationsSucceeded>0</numOperationsSucceeded><estimatedPercentExecuted>0</estimatedPercentExecuted><numResultsWritten>0</numResultsWritten></progressStats><downloadUrl><url>https://batch-job-download-prod-ebe9b43.storage.googleapis.com/122403367/1138360.results.xml?GoogleAccessId=-rbu1gkdushnqrfcf47developer.gserviceaccount.com&amp;Expires=1455896909&amp;Signature=bd5CJk5yGLYmUPgxxw0Xi4KogYFxV0tMCvy%2FgK0a%2BFuPbGkz6XpydQnOZ2EG%2FgoYykWND%2Fi62ftR3s7rBKFCISsMSdXW9rAhfXHJS8cNVPyxDE%2F%2BhHRV58FxSai2N955%2BwY8JFQP7kd93n5exqxM7RfFS4%2F%2F87vv46usI3vhVyE4MTK%2FFgP%2BVvY0wiGd1b%2Bt1hXHJ3aDp5MefyiL9y%2FmQa7%2BnRxeyWfAoZCRkdjhKXcjiNBBxGrUaDBEmd96betUd54Pqo57z1ReDrkZ3TsBC3czapti5lTZrsdnw8luXf9%2BFXEfynBCGM%2Fk2hWIQosHE1RQd%2B1Iq7g9973TUCyb4g%3D%3D</url><expiration>20160219 164829 Europe/Stockholm</expiration></downloadUrl><processingErrors><fieldPath></fieldPath><trigger></trigger><errorString>BatchJobProcessingError.FILE_FORMAT_ERROR</errorString><ApiError.Type>BatchJobProcessingError</ApiError.Type><reason>FILE_FORMAT_ERROR</reason></processingErrors></entries></rval></getResponse></soap:Body></soap:Envelope>

Wheni use download url , Get this in file

<?xml version="1.0" encoding="UTF-8"?><mutateResponse xmlns="https://adwords.google.com/api/adwords/cm/v201509"></mutateResponse>

Is there any thing wrong int he xml code ?

And also it will be veryhelpfull if i can find any example code for java code wihtout client library.

Thank you,

Javeed

Yin Niu

unread,
Jan 20, 2016, 4:02:06 PM1/20/16
to AdWords API Forum
Hi Javeed, 

I would recommend you use the Java library because it has encapsulated the XML parsing for you. For the XML request you have, the only place that I found could be an issue is the <opertions> tag. Please take a look at BatchJobOps.xsd file. You might want to make campaignOperation in a separate tag. 

Thanks,
Yin, AdWords API Team. 

Javeed Syed

unread,
Jan 26, 2016, 9:35:08 AM1/26/16
to AdWords API Forum

Hi Yin,

I understand Java client library is having a good way for doing it with its XML parsing. But we have all the code set for SOAP requests and it was working normally. 
But when am trying to migrated to Batchjobservice it has some issue with uplaoding xml body. I have changed the tag and provided separate tag for campaign. But it is still the same issue, nothing changed.

Is there any thing you can find more from the above..

/Javeed

Nadine Sundquist (AdWords API Team)

unread,
Jan 26, 2016, 8:24:15 PM1/26/16
to AdWords API Forum
Hello Javeed,

Hopefully, you've had a chance to check out the Batch Processing guide while putting this together. I would highly recommend just taking the code you need from the Java library because there are a few gotchas. If you are not going to use the client library, then please at least check out the code here to help structure your own code. You'll see that one of the things you need is that each upload needs to be an increment of 256K. Little things like that can result in error such as the FILE_FORMAT_ERROR.

Best,
Nadine, AdWords API Team
Reply all
Reply to author
Forward
0 new messages