API Request
Copy
const apiUrl = "https://your_nexus_server_or_ip/api/v3/";
//JSON data to be sent
const data = {
"id": "V7b7223454-xxxx-xxxx-xxxx-a2e4353ca05a",
"name": "John",
"lastname": "Doe",
"email": "john@example.com",
"upass": "My5tr0ng!p@ss",
"faenabled": false,
"modfilter": "",
"groups": "V7...,V7...,V7..."
};
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);
});