API Request
Copy
const apiUrl = "https://your_nexus_server_or_ip/api/v3/";
//JSON data to be sent
const data = {
"id": "V75ab57706-xxxx-xxxx-xxxx-0131xxxx1edf",
"name": "cs01 for Dev",
"tags": "dev,test",
"type": "Virtual or Cloud",
"ip": "192.168.22.22",
"privateip": "192.168.20.22",
"zone": "dev.domain.com"
};
const requestOptions = {
method: "POST",
headers: {
"Content-Type": "application/json",
"x-access-account": "YOUR_ACCOUNT_ID",
"x-access-authorization": "YOUR_ACCESS_KEY",
"x-secret-key": "YOUR_SECRET_KEY",
"x-api": "API_NAME",
"x-api-command": "API_COMMAND"
},
body: JSON.stringify(data),
};
fetch(apiUrl, requestOptions)
.then((response) => {
if (!response.ok) {
throw new Error("Connection error");
}
return response.json();
})
.then((data) => {
//process received JSON data
console.log(JSON.stringify(data, null, 4));
if (data.result == "OK") {
console.log("TASK SUCCESSFUL");
} else {
console.log("ERROR: " + data.message);
}
})
.catch((error) => {
console.log("Error: " + error);
});