Search code examples
restazure-sphere

Azure Sphere Public API: Delete device group method not working


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.


Solution

  • 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.

    enter image description here

    with the Admin role, the request is successful.