将Rest Api发布到ODL控制器

时间:2017-05-17 01:35:43

标签: javascript rest opendaylight

我是OpenDaylight控制器的新手,我在尝试使用Rest api发布OpenDaylight时遇到此错误。

function UserAction() {

var xhttp = new XMLHttpRequest();

xhttp.open("POST", "http://localhost:8181/restconf/config/SecAser:SecAser/", 
false);
xhttp.setRequestHeader("Content-type", "application/json");
var parameters={
"attacks": [
{
"id":"4",
"attack-match":"Sniffing",
"etat":"true"
}
]
}
//JSON.stringify(parameters);
xhttp.setRequestHeader("Content-type", "application/json");
xhttp.send(parameters);
var response = JSON.parse(xhttp.responseText);
alert(xhttp.responseText);
}

这是数据源like a database] and this is the error message

2 个答案:

答案 0 :(得分:1)

完成了结构

var parameters ='{"attacks":[{"id":'+getRandomInt(35,45)+',"attack-match":"Sniffing","etat":true}]}';



xhttp.send(parameters);

答案 1 :(得分:0)

您可以在这些OpenDaylight Netvirt Postman collections中找到常用REST请求的示例。