搜索类型: 方法:POST
URL:http:// // beta.etruckingsoft.com:8800/contact/searchContacts
身体:
{"Company Id" : 2,
"SearchVal" : "b",
"Contact Type":"Broker",
"token" : "eyJhbGciOiJIUzI1NiJ9.MTkzMA.g132LGIzcwJaJRGa31q-k1hk6u79H0wIj1xjCJzLpZU"}
CONTACT-TYPE : application/json
如何使用JavaScript,ajax或json方法调用此API?
答案 0 :(得分:0)
const xhr = new XMLHttpRequest(), url="http://beta.etruckingsoft.com:8800/contact/searchContacts", method="POST";
const body = {
"Company Id" : 2,
"SearchVal" : "b",
"Contact Type":"Broker",
"token" : "eyJhbGciOiJIUzI1NiJ9.MTkzMA.g132LGIzcwJaJRGa31q-k1hk6u79H0wIj1xjCJzLpZU"
};
xhr.open(method, url, true);
xhr.onreadystatechange = () => {
if(xhr.readyState === 4 && xhr.status === 200)
console.log(xhr.responseText);
};
xhr.setRequestHeader("Content-type", "application/json;charset=UTF-8");
xhr.send(JSON.stringify(body));