Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cual es el formato response #10

Open
alecamilla opened this issue Apr 22, 2021 · 1 comment
Open

Cual es el formato response #10

alecamilla opened this issue Apr 22, 2021 · 1 comment

Comments

@alecamilla
Copy link

Hola a todos:

Estoy usando
data = {"contact": {"email": email}}
response = client.contacts.create_or_update_contact(data)
if response['contact']['id']:
en algunas ocasiones me entrega este error en el if ->TypeError: string indices must be integers

¿Cual es el formato del response? para poder controlar si viene correctamente o ocurrió un error?

muchas gracias
Saludos

@alecamilla alecamilla changed the title Cual es el formata response Cual es el formato response Apr 22, 2021
@alecamilla
Copy link
Author

alecamilla commented Oct 6, 2021

Lo resolví de la siguiente manera, aca va un ejemplo:
email = '[email protected]'
idsList = 12
data = {"contact": {"email": email}}
response = client.contacts.create_or_update_contact(data)

try:
dato = response.get('contact', '')

  if dato!='':
	  idContact = response['contact']['id']
	  data = { "contactList": {  "list": idsList,  "contact": idContact,  "status": 1 }  }
	 response = client.contacts.update_list_status_for_a_contact(data)
             try:
		dato = response.get('contactList', '')

		if dato=='':
			msn='Error API:'
			if  response['errors'][0]['title']:
				msn = msn + response['errors'][0]['title']
			else:
			msn = msn +'a ocurrido problemas a conectarse.'
					
	except AttributeError:
			pass
			msn = response	  
  elif dato=='':
	  if  response['errors'][0]['title']:
		  msn = 'Error API:' + response['errors'][0]['title']

except AttributeError:
pass
msn = response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant