I tried to use Azure Sphere Public API: Device Group - Delete with Node.js.
But I got error message: Error occurred while deleting deviceGroup --- for tenantId ---
.
(---: my tenant/device group ID)
But the 'Device Group - Get' method worked well. Below is part of the test code.
const config = {
url: `https://prod.core.sphere.azure.net/v2/tenants/${tenantId}/devicegroups/${groupId}`,
headers: {
Authorization: `Bearer ${token}`
},
method: "DELETE"
};
try {
const resp = await axios(config);
console.log("resp:", resp);
} catch (error) {
console.error(error);
}
In config, when I change the method to "GET", it works. But when using the "DELETE" method, an error occurred.
Please check this.
I noticed that the problem is role type.
To use DELETE
method of Azure Sphere Public API, it seems to need an Administrator role.
Before I tested with the Contributor role, so got an error.
with the Admin role, the request is successful.