fix(api): handle different response formats in contact creation
This commit is contained in:
parent
ffb7a50443
commit
27c8ae77c2
1 changed files with 9 additions and 3 deletions
10
api.py
10
api.py
|
|
@ -2841,12 +2841,18 @@ async def creer_contact(numero: str, contact: ContactCreate):
|
||||||
contact.numero = numero
|
contact.numero = numero
|
||||||
|
|
||||||
resultat = sage_client.creer_contact(contact.dict())
|
resultat = sage_client.creer_contact(contact.dict())
|
||||||
return Contact(**resultat)
|
|
||||||
|
if isinstance(resultat, dict) and "data" in resultat:
|
||||||
|
contact_data = resultat["data"]
|
||||||
|
else:
|
||||||
|
contact_data = resultat
|
||||||
|
|
||||||
|
return Contact(**contact_data)
|
||||||
|
|
||||||
except HTTPException:
|
except HTTPException:
|
||||||
raise
|
raise
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Erreur création contact: {e}")
|
logger.error(f"Erreur création contact: {e}", exc_info=True)
|
||||||
raise HTTPException(500, str(e))
|
raise HTTPException(500, str(e))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue