Проблема с Zoho Invocing API {"code": 1038, "message": «JSON сформирован неправильно»} - PullRequest
0 голосов
/ 30 сентября 2018

Я борюсь с API выставления счетов.Поэтому я использую следующий скрипт Python для создания счетов, однако он выглядит ошибочным:

import urllib.parse
import requests
import json
data = {     "customer_id": 982000000567001, "contact_persons": [ "982000000870911", "982000000870915" ], "invoice_number": "INV-00003", "reference_number": " ", "place_of_supply": "TN", "gst_treatment": "business_gst", "gst_no": "22AAAAA0000A1Z5", "template_id": 982000000000143, "date": "2013-11-17", "payment_terms": 15, "payment_terms_label": "Net 15", "due_date": "2013-12-03", "discount": 0, "is_discount_before_tax": "true", "discount_type": "item_level", "is_inclusive_tax": "false", "exchange_rate": 1, "recurring_invoice_id": " ", "invoiced_estimate_id": " ", "salesperson_name": " ", "custom_fields": [ { "label": "Record Number", "value": 23 } ], "project_id": " ", "line_items": [ { "item_id": 982000000030049, "project_id": " ", "time_entry_ids": [ {} ], "expense_id": " ", "name": "Hard Drive", "product_type": "goods", "hsn_or_sac": 80540, "item_order": 1, "rate": 120, "quantity": 1, "unit": " ", "discount": 0, "tax_id": 982000000557028, "tax_exemption_id": 11149000000061054, "tax_name": "VAT", "tax_type": "tax", "tax_percentage": 12.5, "item_total": 120 } ], "payment_options": { "payment_gateways": [ { "configured": "true", "additional_field1": "standard", "gateway_name": "paypal" } ] }, "allow_partial_payments": "true", "custom_body": " ", "custom_subject": " ", "notes": "Looking forward for your business.", "terms": "Terms & Conditions apply", "shipping_charge": 0, "adjustment": 0, "adjustment_description": " ", "reason": " ", "tax_authority_id": 11149000000061052, "tax_exemption_id": 11149000000061054 }
headers = {"content-type": "application/x-www-form-urlencoded;charset=UTF-8","Authorization":"Zoho-authtoken <MY_TOKEN>","X-com-zoho-invoice-organizationid": "<MY_ORGANIZATION_ID>"}
url = "https://invoice.zoho.com/api/v3/invoices"
r = requests.post(url, data=json.dumps(data), headers=headers)

print(r.json())

Что я получаю: {"code": 1038, "message": "JSON не сформирован правильно»}

Можете ли вы помочь мне и скажите, как мне кодировать мои данные?

...