3
我正在做一个任务,我需要与Tastypie API进行交互。我无法控制API,我只是给了它的细节,并告诉它设置为允许GET,POST和DELETE的唯一。Django - Tastypie POST(更新)导致409冲突
例POST - 工程
curl --dump-header - -H "Accept: application/json" -H "Content-Type: application/json" -X POST -d '{"email":"[email protected]","tr_referral":"SomeFeed","mailing_lists":1,"ip_address":"192.168.1.23"}' http://api.somesite.info/v1/account/?username=test\&api_key=a0495db44f4gch749c4gf56906350f336571d94
范例中得到 - 工程
curl http://api.somesite.info/v1/account/202126/?username=test\&api_key=a0495db44f4gch749c4gf56906350f336571d94
GET响应:
{"birth_date": null, "city": "", "country": "nl", "email": "[email protected]", "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":"[email protected]","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 [email protected] already exists.
我也试过张贴到以下网址:
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密钥等
PUT命令呢? –