Google ADS API Customer List - Request contains an invalid argument.","grpc_status":3

15 views
Skip to first unread message

Gjppy

unread,
Jul 25, 2024, 9:39:08 AM (2 days ago) Jul 25
to Google Ads API and AdWords API Forum
hi,

we are trying to import members within a customer list but if the list has more than 6 rows the program fails on apicall.cs in async Task<TResponse> WaitAndCallHandlers() with
Google.Ads.GoogleAds.V17.Errors.GoogleAdsException: 'Status(StatusCode=“InvalidArgument”, Detail=“Request contains an invalid argument.”, DebugException="Grpc.Core.Internal. CoreErrorDetailException: {“created”:“@1721909883.536000000”,“description”:“Error received from peer ipv4:216.58.209.42:443”,“file”:“..\..\..\src\core\lib\surface\call.cc”,“file_line”:953,“grpc_message”:"Request
contains an invalid argument.“, ‘grpc_status’:3}”)'

Internal exception

This is the code:

    Sub Main()

        Dim config As New GoogleAdsConfig()
        config.DeveloperToken = "sdsdsdsdsdsdsdssdsdsdsdsdsadasdasdadas"
        config.OAuth2ClientId = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXapps.googleusercontent.com"
        config.OAuth2ClientSecret = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx2Uwsnrp9Oht00_HL"
        config.OAuth2RefreshToken = "1//09TeASCASDASDASDASDASDASDASDvm7UC-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxwW6f8Qd42hrgBxtD-S-Gg1D0"
        config.LoginCustomerId = "ZZZZZZZZZ"

        Dim client As New GoogleAdsClient(config)

        ' Path to your CSV file.
        Dim csvFilePath As String = "C:\Sviluppo\_A TESTGOOGLE\_A TESTGOOGLE\customer_match.CSV"
        Dim custData As List(Of String()) = ReadCsv(csvFilePath)

        Dim userDa As UserData = New UserData()
        Dim userDataList As List(Of UserData) = New List(Of UserData)()

        ' Create operations to add users to the job.
        For i = 1 To custData.Count - 1
            Dim hashedEmailIdentifier As UserIdentifier = New UserIdentifier() With {
                .HashedEmail = NormalizeAndHash(custData(i)(0))
                }

            Dim hashedPhoneNumberIdentifier As UserIdentifier = New UserIdentifier() With {
                .HashedPhoneNumber = NormalizeAndHash(custData(i)(6))
                }

            Dim addressInfo As OfflineUserAddressInfo = New OfflineUserAddressInfo() With {
                .HashedFirstName = NormalizeAndHash(custData(i)(1)),
                .HashedLastName = NormalizeAndHash(custData(i)(2)),
                .CountryCode = custData(i)(3),
                .PostalCode = custData(i)(4)
                 }

            Dim addressIdentifier As UserIdentifier = New UserIdentifier() With {
                .AddressInfo = addressInfo
                }

            userDa.UserIdentifiers.Add(hashedEmailIdentifier)
            userDa.UserIdentifiers.Add(hashedPhoneNumberIdentifier)
            userDa.UserIdentifiers.Add(addressIdentifier)
            userDataList.Add(userDa)
        Next


        ' Create the job
        Dim job As New OfflineUserDataJob() With {
            .Type = OfflineUserDataJobType.CustomerMatchUserList,
            .CustomerMatchUserListMetadata = New CustomerMatchUserListMetadata() With {
                .UserList = ResourceNames.UserList(customerId, userListId)
            }
        }

        ' Get the OfflineUserDataJobService
        Dim offlineUserDataJobService As OfflineUserDataJobServiceClient = client.GetService(Services.V17.OfflineUserDataJobService)

        ' Create the job and get the job resource name
        Dim createJobResponse As CreateOfflineUserDataJobResponse = offlineUserDataJobService.CreateOfflineUserDataJob(customerId.ToString(), job)
        Dim jobResourceName As String = createJobResponse.ResourceName

        ' Add the user data to the job
        Dim addUserDataJobOperationsResponse As AddOfflineUserDataJobOperationsResponse = offlineUserDataJobService.AddOfflineUserDataJobOperations(jobResourceName, userDataList.Select(Function(userData) New OfflineUserDataJobOperation() With {.Create = userData}).ToList(),)
        Dim w = addUserDataJobOperationsResponse.PartialFailureError
        Console.WriteLine("User data added to user list with job resource name: " & jobResourceName)

    End Sub

    Function ReadCsv(filePath As String) As List(Of String())
        Dim customerData As New List(Of String())
        Using reader As New StreamReader(filePath)
            While Not reader.EndOfStream
                Dim line As String = reader.ReadLine()
                Dim values As String() = line.Split(","c)
                customerData.Add(values)
            End While
        End Using
        Return customerData
    End Function

Public Function NormalizeAndHash(input As String) As String    
        Using sha256 As Security.Cryptography.SHA256 = Security.Cryptography.SHA256.Create()
            Dim normalizedInput As String = input.Trim().ToLower().Replace(" ", "")
            Dim inputBytes As Byte() = System.Text.Encoding.UTF8.GetBytes(normalizedInput)
            Dim hashedBytes As Byte() = sha256.ComputeHash(inputBytes)
            Return BitConverter.ToString(hashedBytes).Replace("-", "").ToLower()
        End Using
    End Function

Google Ads API Forum Advisor

unread,
Jul 25, 2024, 11:39:24 AM (2 days ago) Jul 25
to vall...@gmail.com, adwor...@googlegroups.com
Hi,

Thank you for reaching out to the Google Ads API support team.

Kindly provide us with the complete API logs (request and response logs with request-id and request header) generated at your end, so that we can investigate this issue further on our end and assist you accordingly.

If you are using a client library and haven't enabled logging yet, I would request that you enable logging for the specific client library that you are using. You can refer to the guides Java.NetPHPPythonRuby or Perl to enable logging at your end. For REST interface requests, you can enable logging via the curl command by using the -i flag.

You can send the details via Reply privately to the author option, or direct private reply to this email.
 
This message is in relation to case "ref:!00D1U01174p.!5004Q02vE8XM:ref" (ADR-00259583)

Thanks,

 
Google Logo Google Ads API Team

Register for the upcoming workshop: Performance Max and the Google Ads API!
 


Reply all
Reply to author
Forward
0 new messages