Tastypie API を操作する必要がある課題を行っています。私は API を制御できません。API の詳細を教えてもらったところ、GET、POST、および DELETE のみを許可するように設定されていると言われました。
POST の例 - 動作
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 の例 - 動作
curl http://api.somesite.info/v1/account/202126/?username=test\&api_key=a0495db44f4gch749c4gf56906350f336571d94
GET レスポンス:
{"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": ""}
ここで、レコードの更新をトリガーするために試した多くの POST の 1 つを次に示します。
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 に POST してみました。
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キーなどの一部のデータを変更したことに注意してください