Regarding setting the dynamic budget for the Campaign

36 views
Skip to first unread message

Abhay Desale

unread,
Apr 4, 2019, 3:16:39 PM4/4/19
to AdWords API and Google Ads API Forum
Hello Sir,

I am trying to set the budget at the  campaign level taking values from the json file but getting and error GoogleAdsServerFault: Unmarshalling Error: For input string: "r"

My code is:

def main(client): campaign_service = client.GetService('CampaignService', version='v201809') budget_service = client.GetService('BudgetService', version='v201809') for i in my_json_data.keys(): for j in my_json_data[str(i)].keys(): k=str(j) q=my_json_data[str(i)][j]['Total Suggested Daily Budget'] D = decimal.Decimal r=D(q) r=str(r) budget = { 'name':k+'budget', 'amount':{ 'microAmount': 'r' }, 'deliveryMethod': 'STANDARD' } budget_operations = [{ 'operator': 'ADD', 'operand': budget }] budget_id = budget_service.mutate(budget_operations)['value'][0]['budgetId'] operations = [{ 'operator': 'ADD', 'operand':{ 'name':k, 'status': 'PAUSED', 'advertisingChannelType': 'SEARCH', 'biddingStrategyConfiguration':{ 'biddingStrategyType': 'MANUAL_CPC', }, 'endDate': (datetime.datetime.now() + datetime.timedelta(365)).strftime('%Y%m%d'), 'budget':{ 'budgetId': budget_id }, 'networkSetting':{ 'targetGoogleSearch': 'true', 'targetSearchNetwork': 'true', 'targetContentNetwork': 'false', 'targetPartnerSearchNetwork': 'false' }, 'startDate': (datetime.datetime.now() + datetime.timedelta(1)).strftime('%Y%m%d'), 'frequencyCap':{ 'impressions': '5', 'timeUnit': 'DAY', 'level': 'ADGROUP' }, 'settings':[ { 'xsi_type': 'GeoTargetTypeSetting', 'positiveGeoTargetType': 'DONT_CARE', 'negativeGeoTargetType': 'DONT_CARE' } ] } },] campaigns = campaign_service.mutate(operations) for campaign in campaigns['value']: print ('Campaign with name "%s" and id "%s" was added.' % (campaign['name'], campaign['id'])) if __name__ == '__main__': # Initialize client object. adwords_client = adwords.AdWordsClient.LoadFromStorage() main(adwords_client)


Please help out me with some solution.

Thanks and Regards,
Abhay

googleadsapi...@google.com

unread,
Apr 5, 2019, 1:46:51 AM4/5/19
to AdWords API and Google Ads API Forum
Hi Abhay,

Thank you for reaching out. Upon checking, the error that you are encountering seems to be related more to the client library. You can reach out to the python client library owners through this link in Github as they are better equipped to assist you for this matter.

Regards,
Dave Paurillo
Google Ads API Team


=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and discussion group:
    https://ads-developers.googleblog.com/search/label/google_ads_api
    https://developers.google.com/adwords/api/community/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

Was your question answered? Please rate your experience with us by taking a short survey.
If not -- reply to this email and tell us what else we can do to help.

Take Survey

Also find us on our blog and discussion group:
http://googleadsdeveloper.blogspot.com/search/label/adwords_api
https://developers.google.com/adwords/api/community/

--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
 
You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads API Forum" group.
To post to this group, send email to adwor...@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 and Google Ads 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/1760c2e9-7031-4728-bf57-bd8c9e22acea%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages