Код: Выделить всё
async def create_invoice(
invoice_detail: InvoiceCreateRequest,
token_manager=Depends(oauth_manager)
) -> InvoiceCreateResponse:
base_url = 'https://api.xero.com/api.xro/2.0/Invoices'
headers = {
'Xero-Tenant-Id': get_settings().TENANT_ID,
'Accept': 'application/json',
'Content-Type': 'application/json',
'Authorization': f'Bearer {await token_manager.access_token}'
}
data = invoice_request_to_dict(invoice_detail)
async with httpx.AsyncClient() as client:
response = await client.request(
method='POST',
url=base_url,
headers=headers,
data=data
)
Код: Выделить всё
{
"Type": "ACCREC",
"Contact": {
"ContactID": "3ed357da-0988-4ea1-b1b7-96829e0dde69"
},
"DueDate": r"\/Date(1518685950940+0000)\/",
"LineItems": [
{
"Description": "Services as agreed",
"Quantity": "4",
"UnitAmount": "100.00",
"AccountCode": "200"
}
],
"Status": "AUTHORISED"
}
Код: Выделить всё
b'{\r\n "ErrorNumber": 14,\r\n "Type": "PostDataInvalidException",\r\n "Message": "Invalid Json data"\r\n}'
Код: Выделить всё
'\\/Date(1518685950940+0000)\\/'Код: Выделить всё
JSON for post data was invalid,Could not convert string to DateTime: \/Date(1518685950940+0000)\/. Path 'DueDate', line 6, position 45.
Подробнее здесь: https://stackoverflow.com/questions/793 ... e-api-call
Мобильная версия