Hello!
I’m using CODE by Zapier tu run a POST request in order to save contacts to my CRM platform.
The problem is that some contacts names or last names have special characters such as accent marks (á, é, í, ó, ú) or the letter “ñ”
I’m using Python Request to send the POST Request and adding the value to the JSON as shown below:
import http.client
conn = http.client.HTTPSConnection("api.icommarketing.com")
payload = "{\r\n \"ProfileKey\":\""SECRET KEY]\", \r\n\"Contact\":\r\n{\"Email\":\""+input_data"'email']+"\",\r\n \"CustomFields\":"\r\n{\"Key\":\"d_first_name\",\"Value\":\""+input_data"'nombre']+"\"},\r\n{\"Key\":\"d_last_name\",\"Value\":\"Neiva\"},\r\n{\"Key\":\"d_celular\",\"Value\":\"Neiva\"},\r\n{\"Key\":\"q88696_ltbgtconoces_y_aceptas_la_poli\",\"Value\":\"Neiva\"}\r\n ]\r\n}\r\n}\r\n"
headers = {
'Authorization': 'uSECRET KEY]',
'Content-Type': 'application/json',
'Cookie': 'ASP.NET_SessionId=4sbyadeh0bgrlimefr2abzpk'
}
conn.request("POST", "/Contacts/SaveContact.Json/", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
Everytime the action faces a special character or a “ñ” it generates error code. The example above returns error since the input field number is equal to “Lucás”, with the accent mark on the “a” letter.
Is there a way to include the variables in the JSON ignoring these special characters?
Thanks in advance