Tastypieを使用してAPIを作成していますが、バックボーンからAPIにアクセスしたいと思います。クレデンシャルを送信するには、user_idとapi_keyを使用します。私はこれをAndroidとcurlで行い、これはうまく機能しますが、バックボーンからhttpヘッダーを設定できます。
カールで私は使用します:
curl --dump-header - -H "Accept: application/json" -H "Content-Type: application/json" -H "user_id: 32" -H "api_key: 69950" -X DELETE "http://127.0.0.1:8000/api/v1/deletenote/66/?format=json"
そしてアンドロイドJavaで私は使用します:
HttpDelete requestDELETE = new HttpDelete();
requestDELETE.setHeader("Content-type", "application/json");
requestDELETE.setHeader("Accept", "application/json");
requestDELETE.setHeader(Constants.HEADER_USER_ID, user_id);
requestDELETE.addHeader(Constants.HEADER_API_KEY, key);
どちらもうまく機能しますが、ページの他の投稿で見つけた応答に従ってBackboneでこれを試してみると、機能しませんでした。
私はこれを試しています:
var removeNote = new DeleteNoteModel({id:this.model.toJSON().id},{ query:this.model.toJSON().id});
removeNote.destroy({
headers: {'user_id':dataWeb.get("id"),'api_key':dataWeb.get("api_key")}
},{
async:false,
error: function(model, response){
console.log("KO_REMOVE_NOTE");
console.log(response);
},
success : function(model, response){
console.log("OK_REMOVE_NOTE");
console.log(response);
}
}
);
destroy呼び出しを呼び出すときにヘッダーを配置していますが、これはサーバーにanithingを送信しません。
私は間違ったモードで何をしていますか?
ありがとうございます。