Google AdWords API - AdGroupAdError CANNOT_CREATE_DEPRECATED_ADS - python

I'm using Google AdWords Python SDK to create ResponsiveDisplayAds. My code is like below.
adgroup_ad_service = adwords_client.GetService(
service_name = "AdGroupAdService",
version = "v201809"
)
operations = [{
'operator': 'ADD',
'operand': {
'xsi_type': 'AdGroupAd',
'adGroupId': '<AD_GROUP_ID>',
'ad': {
'xsi_type': 'ResponsiveDisplayAd',
'marketingImage': {
'mediaId': '<MEDIA_ID>'
},
'shortHeadline': 'Short Headline',
'longHeadline': 'This is a very long headline',
'description': 'This is a description',
'businessName': 'Test Business Name',
'finalUrls': ['https://www.google.com'],
'squareMarketingImage': {
'mediaId': '<MEDIA_ID>'
}
},
'status': 'PAUSED'
}
}]
ads_response = adgroup_ad_service.mutate(operations)
print("AD RESPONSE : {}".format(ads_response))
But It's giving me, AdGroupAdError.CANNOT_CREATE_DEPRECATED_ADS.
According to the documentation it describe this error as An ad of this type is deprecated and cannot be created. Only deletions are permitted..
But in documentation of the AdGroupAd ResponsiveDisplayAd, is one of the accepted Ad types.
So it would be great if someone can point me a direction to resolve this issue.

Use AddMultiAssetResponsiveDisplayAd instead.
Same result in a different way.
Hope you can make it like i did.

Related

Error in creation of work-item in Azure DevOps using Pytest/Python

I am trying to create a work-item using Python and requests library.
def test_create_work_item(work_items):
payload = {
'op': 'add',
'path': '/fields/System.Title',
'value': 'Sample bug'
}
pl = json.dumps(payload)
work_item = work_items.create(body=pl, type='bug')
assert work_item.status_code == 200
I am getting the below error for this :
{"$id":"1","innerException":null,"message":"You must pass a valid patch document in the body of the request.","typeName":"Microsoft.VisualStudio.Services.Common.VssPropertyValidationException,Microsoft.VisualStudio.Services.Common","typeKey":"VssPropertyValidationException","errorCode":0,"eventId":3000}
The same body works okay with Postman. So not sure what more is needed here to get it working.
I`m not familiar with Python.... Check this example: Create work item
The API uses an array of new fields:
[
{
"op": "add",
"path": "/fields/System.Title",
"from": null,
"value": "Sample task"
}
]
In your case, you use just one field in the request:
{
'op': 'add',
'path': '/fields/System.Title',
'value': 'Sample bug'
}

Google Drive Export (Google Vault) for Specific User

Following the docs, there's an example to export all for a specific OU
def create_drive_ou_all_data_export(service, matter_id):
ou_to_search = 'ou id retrieved from admin sdk'
drive_query_options = {'includeSharedDrives': True}
drive_query = {
'corpus': 'DRIVE',
'dataScope': 'ALL_DATA',
'searchMethod': 'ORG_UNIT',
'orgUnitInfo': {
'org_unit_id': ou_to_search
},
'driveOptions': drive_query_options,
'startTime': '2017-03-16T00:00:00Z',
'endTime': '2017-09-23T00:00:00Z',
'timeZone': 'Etc/GMT+2'
}
drive_export_options = {'includeAccessInfo': False}
wanted_export = {
'name': 'My first drive ou export',
'query': drive_query,
'exportOptions': {
'driveOptions': drive_export_options
}
}
return service.matters().exports().create(
matterId=matter_id, body=wanted_export).execute()
However, it does not show how to just export for a given user, is this possible? Also, where are all of the different body options for creating an export? The examples do not seem to show all of the parameters available.
You'd want to use searchMethod:account
Reference Query: https://developers.google.com/vault/reference/rest/v1/Query
Reference searchmethod: https://developers.google.com/vault/reference/rest/v1/Query#SearchMethod
Reference AccountInfo: https://developers.google.com/vault/reference/rest/v1/Query#AccountInfo
drive_query = {
'corpus': 'DRIVE',
'dataScope': 'ALL_DATA',
'searchMethod': 'ACCOUNT', # This is different
'accountInfo': { # This is different
'emails': ['email1#company.com', 'email2#company.com', 'email3#company.com']
},
'driveOptions': drive_query_options,
'startTime': '2017-03-16T00:00:00Z',
'endTime': '2017-09-23T00:00:00Z',
'timeZone': 'Etc/GMT+2'
}

How to update google doc using google docs api (Python)

I'm new to Google Docs api and want to be able to add text using the replaceText option. How would I set this up? I am doing this in Python 3.6
Just follow the steps from Google Docs API quickstart using Python. Then try to run this code to insert text using InsertTextRequest method:
requests = [
{
'insertText': {
'location': {
'index': 25,
},
'text': text1
}
},
{
'insertText': {
'location': {
'index': 50,
},
'text': text2
}
},
{
'insertText': {
'location': {
'index': 75,
},
'text': text3
}
},
]
result = service.documents().batchUpdate(
documentId=DOCUMENT_ID, body={'requests': requests}).execute()
To insert text into a document, use the BatchUpdate method and include an InsertTextRequest with the text and location as the payload. It's better to use this suggested method in the documentation.

Set customer ID for Google Adwords API

I try to use the Google Adwords API, with the official library here : https://github.com/googleads/googleads-python-lib
I use an Manager Account on Google Adwords and want to work with my client's accounts.
I can get all the the Adwords account ID (like 123-456-7891) but I don't know how to pass the account ID to my Google Adwords functions as a parameter.
Here's my main function :
def main(argv):
adwords_client = adwords.AdWordsClient.LoadFromStorage(path="googleads.yaml")
add_campaign(adwords_client)
I see any Account ID parameter in the official samples, as :
import datetime
import uuid
from googleads import adwords
def add_campaign(client):
# Initialize appropriate services.
campaign_service = client.GetService('CampaignService', version='v201809')
budget_service = client.GetService('BudgetService', version='v201809')
# Create a budget, which can be shared by multiple campaigns.
budget = {
'name': 'Interplanetary budget #%s' % uuid.uuid4(),
'amount': {
'microAmount': '50000000'
},
'deliveryMethod': 'STANDARD'
}
budget_operations = [{
'operator': 'ADD',
'operand': budget
}]
# Add the budget.
budget_id = budget_service.mutate(budget_operations)['value'][0][
'budgetId']
# Construct operations and add campaigns.
operations = [{
'operator': 'ADD',
'operand': {
'name': 'Interplanetary Cruise #%s' % uuid.uuid4(),
# Recommendation: Set the campaign to PAUSED when creating it to
# stop the ads from immediately serving. Set to ENABLED once you've
# added targeting and the ads are ready to serve.
'status': 'PAUSED',
'advertisingChannelType': 'SEARCH',
'biddingStrategyConfiguration': {
'biddingStrategyType': 'MANUAL_CPC',
},
'endDate': (datetime.datetime.now() +
datetime.timedelta(365)).strftime('%Y%m%d'),
# Note that only the budgetId is required
'budget': {
'budgetId': budget_id
},
'networkSetting': {
'targetGoogleSearch': 'true',
'targetSearchNetwork': 'true',
'targetContentNetwork': 'false',
'targetPartnerSearchNetwork': 'false'
},
# Optional fields
'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'
}
]
}
}, {
'operator': 'ADD',
'operand': {
'name': 'Interplanetary Cruise banner #%s' % uuid.uuid4(),
'status': 'PAUSED',
'biddingStrategyConfiguration': {
'biddingStrategyType': 'MANUAL_CPC'
},
'endDate': (datetime.datetime.now() +
datetime.timedelta(365)).strftime('%Y%m%d'),
# Note that only the budgetId is required
'budget': {
'budgetId': budget_id
},
'advertisingChannelType': 'DISPLAY'
}
}]
campaigns = campaign_service.mutate(operations)
How can I tell Adwords API in which account I want to add this campaign ?
Thanks for your help !
OK my bad, I missed a documentation method (http://googleads.github.io/googleads-python-lib/googleads.adwords.AdWordsClient-class.html#SetClientCustomerId).
# ID of your customer here
CUSTOMER_SERVICE_ID = '4852XXXXX'
# Load customer account access
client = adwords.AdWordsClient.LoadFromStorage(path="googleads.yaml")
client.SetClientCustomerId(CUSTOMER_SERVICE_ID)
And the customer ID is now associate with the AdwordsClient variable as "client" set as parameters for other functions.

JIRA Python Setting Cascading Select Values

I am using the jira-python library to create an issue in JIRA. However I cannot get the syntax right for setting Cascading Select values. The code below creates an issue and works for the first(parent) select in the cascading select but not the second (child). Can anyone tell me what I'm missing?
from jira import JIRA
jira = JIRA(options,basic_auth=('auth_email','auth_pw'))
issue_dict = {
'project': {'key': 'AT'}, #key for project
'summary': 'Summary Message',
'description': 'Not important',
'issuetype': {'name': 'Bug'},
'customfield_10207':{'value': 'test val2'}, #Updates first cascading select
'customfield_10207+1':{'value': 'test test2'}, #Fails
}
new_issue = jira.create_issue(fields=issue_dict)
(customfield_10207, customfield_10207+1 is the cascading select). Problem is with customfield_10207+1 which I expected to correspond to the second select list.
Looking at some atlassian forum docs you need to do the following:
{
"update" : {
"customfield_11272" : [{"set" : {"value" : "External Customer (Worst)","child": {"value":"Production"}}}]
}
}
Apparently the + and : syntax doesn't work :(
Update:
Adding the actual solution:
issue_dict = { 'project': {'key': 'AT'}, 'customfield_10207 : {"value" : "test val2","child": {"value":"test test2"}}, }

Categories