Assignment not allowed to repeated field "conversions" in protocol message object

2,500 views
Skip to first unread message

panu.kuu...@hopkins.fi

unread,
Jan 6, 2022, 1:14:40 PM1/6/22
to AdWords API and Google Ads API Forum
The code sample in https://developers.google.com/google-ads/api/docs/conversions/upload-clicks?hl=en#python seems to have an issue. 

This line request.conversions = [click_conversion] returns an error:

AttributeError: Assignment not allowed to repeated field "conversions" in protocol message object.

My click_conversions looks like: 

gclid: "Cj0KCQiAw9qOBhC-ARIsAG-rdn7H0PLLPzj19IIWAKcoYz63zoYwV4Ca-_82RkyvIVAVPSGTHvHpnAIaAi5_EALw_wcB"
conversion_action: "customers/000000000/conversionActions/000000"
conversion_date_time: "2022-01-06 19:30:06+02:00"
conversion_value: 1.28
currency_code: "USD"
custom_variables {
  conversion_custom_variable: "type"
  value: "purchase"
}

I suppose one is not allowed to assign to repeated fields but I don't see how to proceed. I think appending with request.conversions.append(click_conversion) creates a malformed request.

Anyone got a clue on how to get this to work?

Thank you for your help

panu.kuu...@hopkins.fi

unread,
Jan 12, 2022, 4:58:03 AM1/12/22
to Google Ads API and AdWords API Forum
Solution:

request.conversions.append(click_conversion)
request.partial_failure = True
conversion_upload_response = (
conversion_upload_service.upload_click_conversions(
request=request,
)
)
request.conversions[:0]
Reply all
Reply to author
Forward
0 new messages