Hi, 
*I very need your help!*
I use *upload_offline_conversion.py* from *GoogleAdsAPi Python Github 
Examples*
*https://github.com/googleads/google-ads-python/blob/main/examples/remarketing/upload_offline_conversion.py*

*The request-*
customer_id: "1835092711"
conversions {
  gclid: 
"CjwKCAiA6seQBhAfEiwAvPqu11BHp23yyN-2oMjc102zAjw71o6cXh8Owj21wb827pEb6rKYVWdtYxoCBt0QAvD_BwE"
  conversion_action: "customers/1835092711/conversionActions/259332678"
  conversion_date_time: "2022-02-21 08:21:58-00:00"
  conversion_value: 0.0
  currency_code: "USD"
}
partial_failure: true



*The response-*
request_id: "K1UmED1oQWgH8z_xCo-zRQ"

error_code {
  authorization_error: ACTION_NOT_PERMITTED
}
message: "The user does not have permission to perform this action on the 
resource or call a method."



*This is the code-*

import argparse
import sys
import os

from google.ads.googleads.client import GoogleAdsClient
from google.ads.googleads.errors import GoogleAdsException


# [START upload_offline_conversion]
def main(
client,
customer_id,
conversion_action_id,
gclid,
conversion_date_time,
conversion_value,
conversion_custom_variable_id,
conversion_custom_variable_value,
):

click_conversion = client.get_type("ClickConversion")
conversion_action_service = client.get_service("ConversionActionService")
click_conversion.conversion_action = (
conversion_action_service.conversion_action_path(
customer_id, conversion_action_id
)
)
click_conversion.gclid = gclid
click_conversion.conversion_value = float(conversion_value)
click_conversion.conversion_date_time = conversion_date_time
click_conversion.currency_code = "USD"

if conversion_custom_variable_id and conversion_custom_variable_value:
conversion_custom_variable = client.get_type("CustomVariable")
conversion_custom_variable.conversion_custom_variable = (
conversion_custom_variable_id
)
conversion_custom_variable.value = conversion_custom_variable_value
click_conversion.custom_variables.append(conversion_custom_variable)

conversion_upload_service = client.get_service("ConversionUploadService")
request = client.get_type("UploadClickConversionsRequest")
request.customer_id = customer_id
# request.conversions = [click_conversion]
request.conversions.append(click_conversion)
request.partial_failure = True
conversion_upload_response = (
conversion_upload_service.upload_click_conversions(
request=request,
)
)

uploaded_click_conversion = conversion_upload_response.results[0]
print(
f"Uploaded conversion that occurred at "
f'"{uploaded_click_conversion.conversion_date_time}" from '
f'Google Click ID "{uploaded_click_conversion.gclid}" '
f'to "{uploaded_click_conversion.conversion_action}"'
)
# [END upload_offline_conversion]


if __name__ == "__main__":
dir_path = os.path.dirname(os.path.realpath(__file__))

# credentials dictonary
creds = {"google_ads": dir_path + "/googleads.yaml", "gng_google_ads": 
dir_path + "/gng-googleads.yaml"}

if not os.path.isfile(creds["google_ads"]) and not 
os.path.isfile(creds["gng_google_ads"]):
raise FileExistsError("File doesn't exists. Please create folder src/creds 
and put googleads.yaml file there. ")

googleads_client = GoogleAdsClient.load_from_storage(creds["google_ads"])

parser = argparse.ArgumentParser(
description="Uploads an offline conversion."
)
# The following argument(s) should be provided to run the example.
parser.add_argument(
"-c",
"--customer_id",
type=str,
required=True,
help="The Google Ads customer ID.",
)
parser.add_argument(
"-a",
"--conversion_action_id",
type=str,
required=True,
help="The conversion action ID.",
)
parser.add_argument(
"-g",
"--gclid",
type=str,
required=True,
help="The Google Click Identifier ID "
"(gclid) which should be newer than the number of "
"days set on the conversion window of the conversion "
"action.",
)
parser.add_argument(
"-t",
"--conversion_date_time",
type=str,
required=True,
help="The date and time of the "
"conversion (should be after the click time). The "
'format is "yyyy-mm-dd hh:mm:ss+|-hh:mm", e.g. '
"“2019-01-01 12:32:45-08:00”",
)
parser.add_argument(
"-v",
"--conversion_value",
type=str,
required=True,
help="The conversion value.",
)
parser.add_argument(
"-w",
"--conversion_custom_variable_id",
type=str,
help="The ID of the conversion custom variable to associate with the 
upload.",
)
parser.add_argument(
"-x",
"--conversion_custom_variable_value",
type=str,
help="The value of the conversion custom variable to associate with the 
upload.",
)
args = parser.parse_args()

try:
main(
googleads_client,
args.customer_id,
args.conversion_action_id,
args.gclid,
args.conversion_date_time,
args.conversion_value,
args.conversion_custom_variable_id,
args.conversion_custom_variable_value,
)
except GoogleAdsException as ex:
print(
f'Request with ID "{ex.request_id}" failed with status '
f'"{ex.error.code().name}" and includes the following errors:'
)
for error in ex.failure.errors:
print(f'\tError with message "{error.message}".')
if error.location:
for field_path_element in error.location.field_path_elements:
print(f"\t\tOn field: {field_path_element.field_name}")
sys.exit(1)


-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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 adwords-api@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscr...@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 
"Google Ads API and AdWords API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to adwords-api+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/945b999c-04d3-4485-91b5-0b8bb79705d6n%40googlegroups.com.

Reply via email to