Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/287.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 尝试使用PyXero将时间表上载到Xero时的响应405_Python_Python 3.x_Xero Api - Fatal编程技术网

Python 尝试使用PyXero将时间表上载到Xero时的响应405

Python 尝试使用PyXero将时间表上载到Xero时的响应405,python,python-3.x,xero-api,Python,Python 3.x,Xero Api,库=pyxero 0.9.1 嘿,那里 我试图使用Python将时间表自动上传到Xero,但遇到了一个障碍。 我使用API检索信息没有问题,但当我尝试发布新的时间表时,我得到了405响应代码。我试图将JSON数据简化到Xero允许的最低限度,但错误仍然存在。下面是示例代码 from xero import Xero import configs import datetime from xero.auth import PrivateCredentials credentials = Priva

库=pyxero 0.9.1

嘿,那里

我试图使用Python将时间表自动上传到Xero,但遇到了一个障碍。 我使用API检索信息没有问题,但当我尝试发布新的时间表时,我得到了405响应代码。我试图将JSON数据简化到Xero允许的最低限度,但错误仍然存在。下面是示例代码

from xero import Xero
import configs
import datetime
from xero.auth import PrivateCredentials
credentials = PrivateCredentials(configss.key, configss.RSAstr)
xero = Xero(credentials)

employees = xero.payrollAPI.employees.all()

timesheets = {'timesheets': {'timesheet': {'EmployeeID': employees[0]["EmployeeID"],
              'StartDate': datetime.datetime(2018,8,15),
              'EndDate': datetime.datetime(2018,8,21),
              'Status': 'Draft'}}}

xero.payrollAPI.timesheets.put(timesheets)
请注意,我可以毫无问题地发布新联系人和发票。 在app.xero.com网站上查看我的API调用历史记录时,我看到一条带有

请求消息=

    <Timesheets><Timesheet><EmployeeID>38fcaf73-e35c-4f38-9ebe-642ef6d5b7c7</EmployeeID> 
<StartDate>2018-09-15</StartDate><EndDate>2018-09-21</EndDate> 
<Status>DRAFT</Status></Timesheet></Timesheets>
38fcaf73-e35c-4f38-9ebe-642ef6d5b7c7
2018-09-152018-09-21 
草稿
回应
405-不允许使用方法

您的描述中说的是POST,但代码中说的是“put”-文档-建议使用的方法是POST


如果您将代码切换为“post”,是否达到预期效果?

您可以使用图例!!我在这里撞到了头,真不敢相信我错过了。xero.payrollAPI.timesheets.save(timesheets)成功了!!