我正在尝试将curl
命令转换为ajax
来电,但我一直收到错误请求。这是我的curl
:
curl -X POST --header "Content-Type: application/json" --header "Accept: application/json" -d "{
\"first_name\": \"Bob\",
\"last_name\": \"Dole\",
\"address\": {
\"street_number\": \"123\",
\"street_name\": \"apple st.\",
\"city\": \"Miami Beach\",
\"state\": \"FL\",
\"zip\": \"33140\"
}
}" "http://api.reimaginebanking.com/customers?key=bb67d82asdr32r93927282920159874"
我试过了:
$.ajax({
url: "http://api.reimaginebanking.com/customers?key=bb67d82asdr32r93927282920159874",
type: "POST",
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
},
data: {
first_name: "Bob",
last_name: "Dole",
address: {
street_number: "123",
street_name: "apple st.",
city: "Miami Beach",
state: "NJ",
zip: "33141"
},
},
success: function(data) {
console.log(JSON.stringify(data));
}
});
我收到此错误:400 (Bad Request)
。我究竟做错了什么?任何帮助,将不胜感激!谢谢!