【发布时间】:2021-09-17 15:24:25
【问题描述】:
我一直在做一个需要发送传真的 django 项目。
我使用interfax python library发送传真。
要从 html 生成 pdf,我使用的是 xhtml2pdf。
我像下面这样写,它没有用并引发错误。
我不知道现在该怎么办。
请帮忙。
代码
# interfax authentication
interfax_password = config("INTERFAX_PASSWORD")
interfax_account = config("INTERFAX_ACCOUNT")
interfax = InterFAX(username=interfax_account, password=interfax_password)
f = File(interfax, pdf, mime_type="application/pdf")
fax_number = config("INTERFAX_DESTINATION")
# actually sending the data
fax = interfax.outbound.deliver(fax_number=fax_number, files=[f])
抛出的错误
equests.exceptions.HTTPError: 400 Client Error: Bad Request for url:https://rest.interfax.net/outbound/faxes?faxNumber=111111111
先感谢您
【问题讨论】:
-
当我打印像这样 print(f.headers) 这样的标题时,我发现它是空的。
-
应该是Content-Type: application/pdf。你有什么想法吗?
标签: python html django pdf interfax