I am using the Axios library to make an HTTP GET request to an endpoint on a camera device
const axios = require('axios');
const fs = require('fs');
const username = 'admin';
const password = 'sdsadasadsa';
const cameraIP = '192.168.dummy.dummy';
// Make the GET request with basic authentication
async function makeAuthenticatedGetRequest() {
const uri = 'ISAPI/Security/userCheck?format=json';
const url = `http://${cameraIP}/${uri}`;
const auth = {
username: username,
password: password,
};
try {
const response = await axios.get(url, { auth });
console.log(response.data);
const responseData = JSON.stringify(response.data.data, null, 2);
fs.writeFile('output.json', responseData, (err) => {
if (err) {
console.log(err);
} else {
console.log('File saved!');
}
});
} catch (error) {
console.error(error);
}
}
makeAuthenticatedGetRequest();
The response I’m getting is:
{
"statusCode": 4,
"statusString": "Invalid Operation",
"subStatusCode": "invalidOperation",
"errorCode": 1073741830,
"errorMsg": "unknow"
}
I will be getting this response only when I get 401 unauthorized error
3