amocrm_api icon indicating copy to clipboard operation
amocrm_api copied to clipboard

Требуется помощь в создании сделки

Open kpak3h opened this issue 2 years ago • 1 comments

Добрый день! Не получается создать сделку, чаще всего ошибка "400"

Пробовал создать что-то типо подобного, но не выходит lead = Lead.objects.create(pepiline=1111111, phone=1111111, name=11111) lead.save()

С АПИ до этого не работал, возможно нужно добавить поля или что-то ещё? Посмотрел темы до этого и не особо понял

kpak3h avatar Dec 18 '23 13:12 kpak3h

@kpak3h ``def create_lead_in_amocrm(_process, _person, _document, _source_language, _target_language, _is_sworn, file_id): class Lead(_Lead): # Находим кастомные поля process = custom_field.TextCustomField("process") person = custom_field.TextCustomField("person") document_type = custom_field.TextCustomField("document_type") source_language = custom_field.TextCustomField("source_language") target_language = custom_field.TextCustomField("target_language") is_sworn = custom_field.TextCustomField("is_sworn") document_file = custom_field.TextCustomField("document_file")

	try:
		# Создание новой сделки
		new_lead = Lead(
				name="Новая сделка 10",  # Название нужно будет генерировать новое
				pipeline=7567610,  # Воронка
				status=62673734,  # Этап
		)
		# Добавление значений в кастомные поля
		new_lead.process = _process
		new_lead.person = _person
		new_lead.document_type = _document
		new_lead.source_language = _source_language
		new_lead.target_language = _target_language
		new_lead.is_sworn = _is_sworn

		#  Метод для сохранения сделки
		new_lead.save()

		

		
		
		
		return jsonify({"translation_status": "accepted"})

	except Exception as e:
		print(f"Error creating lead: {e}")
		return False

``

NikolaiKryshnev avatar Dec 29 '23 11:12 NikolaiKryshnev