Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/19.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 Django-Tastypie POST(更新)导致409冲突_Python_Django_Post_Tastypie - Fatal编程技术网

Python Django-Tastypie POST(更新)导致409冲突

Python Django-Tastypie POST(更新)导致409冲突,python,django,post,tastypie,Python,Django,Post,Tastypie,我正在做一个作业,我需要与一个tastypieapi交互。我对API没有控制权,我只是得到了它的详细信息,并被告知它只允许GET、POST和DELETE 作品范例 curl --dump-header - -H "Accept: application/json" -H "Content-Type: application/json" -X POST -d '{"email":"test@someemail.com","tr_referral":"SomeFeed","mailing_l

我正在做一个作业,我需要与一个tastypieapi交互。我对API没有控制权,我只是得到了它的详细信息,并被告知它只允许GET、POST和DELETE

作品范例

curl --dump-header - -H "Accept: application/json" -H "Content-Type: application/json" -X     POST -d '{"email":"test@someemail.com","tr_referral":"SomeFeed","mailing_lists":1,"ip_address":"192.168.1.23"}' http://api.somesite.info/v1/account/?username=test\&api_key=a0495db44f4gch749c4gf56906350f336571d94
示例GET-works

curl http://api.somesite.info/v1/account/202126/?username=test\&api_key=a0495db44f4gch749c4gf56906350f336571d94
获取响应:

{"birth_date": null, "city": "", "country": "nl", "email": "test@someemail.com", "first_name": "", "gender": "", "last_name": "", "lead": true, "mailing_lists": [{"name": "Classic NL", "resource_uri": "/v1/mailing_list/1/"}], "phone": "", "resource_uri": "/v1/account/202126/", "street_number": "", "tr_input_method": "", "tr_ip_address": "192.168.1.23", "tr_language": "", "tr_referral": {"name": "SomeFeed", "resource_uri": ""}, "utm_campaign": "", "utm_medium": "", "utm_source": "SomeFeed", "zipcode": ""}
下面是我为触发记录更新而尝试的许多帖子之一:

curl --dump-header - -H "Accept: application/json" -H "Content-Type: application/json" -X POST -d '{"email":"test@someemail.com","tr_referral":"SomeFeed","mailing_lists":2,"ip_address":"192.168.1.46"}' http://api.somesite.info/v1/account/?username=test\&api_key=a0495db44f4gch749c4gf56906350f336571d94
其结果是:

HTTP/1.1 409 CONFLICT
Server: nginx/1.2.1
Date: Wed, 14 Nov 2012 20:42:35 GMT
Content-Type: text/html; charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive

Email address test@someemail.com already exists.
我还尝试将其发布到以下URL:

http://api.somesite.info/v1/account/202126/?username=test\&api_key=a0495db44f4gch749c4gf56906350f336571d94
结果是:

HTTP/1.1 501 NOT IMPLEMENTED
Server: nginx/1.2.1
Date: Wed, 14 Nov 2012 20:45:01 GMT
Content-Type: text/html; charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
我需要用POST更新记录。我做错了什么


请注意,我已经更改了一些数据,例如URL、api密钥等

我想我应该来提供一个“答案”

事实证明,任务文档中所写的内容具有误导性,我不会通过帖子更新帐户,因为不允许使用此功能

他们真正想要的是我删除账户,然后重新发布,这似乎不是最好的方式,因为每次“更新”都需要两个API调用,而不仅仅是一个。甚至不能使用补丁命令