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

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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/550d3a7f-f193-44e9-99e9-1ef2f21a0f0dn%40googlegroups.com.

Reply via email to