How do I use Hexnode API with terminal on Mac?Solved

Participant
Discussion
1 month ago

Hey there, 

I have a quick question about running Hexnode APIs. I’ve used Postman before, but I haven’t tried running any Hexnode Apis yet. I’m experimenting with using the terminal on my Mac since I heard it’s actually more convenient that way. Can someone walk me through how to do it? 

Replies (5)

Marked SolutionPending Review
Participant
4 weeks ago
Marked SolutionPending Review

To be honest, it’s pretty simple. Just open your terminal and run the API you want to execute.

Hexnode’s APIs are listed in the Hexnode API documentation:
https://www.hexnode.com/mobile-device-management/developers/

For example, if you want to run the api for the Scan device action:
Go to that Api in the documentation, and you’ll see both the HTTP request and the Shell command. You’ll want the shell command:

curl  -H "Authorization: " -H "Content-Type: application/json" -d "{\"users\":[0],\"usergroups\":[4],\"devices\":[5,6],\"devicegroups\":[12]}" https://portalname.hexnodemdm.com/api/v1/actions/scan_device/ 

Just substitute the necessary details (like your Api key, portal Url, and relevant IDs), run it in your terminal, and you’ll see the result reflected in the portal.

Marked SolutionPending Review
Participant
4 weeks ago
Marked SolutionPending Review

I assume we need to replace https://portalname.hexnodemdm.com/ with our portal Url. But what about the Api key—where do I get that from?

Marked SolutionPending Review
Participant
3 weeks ago
Marked SolutionPending Review

You’ll find your Api key in the hexnode portal. 

Go to the Admin tab and look for the API section. Your unique Api key will be available there. 

Marked SolutionPending Review
Participant
3 weeks ago
Marked SolutionPending Review

Thanks! One last thing—I’m not sure where to find the values for users, devices, usergroups, etc. Any tips?

Marked SolutionPending Review
Participant
2 weeks ago
Marked SolutionPending Review

The easiest way is to open the user, device, user group, or device group in the portal and check the url.

For example:
When you open a user group, the Url will look like this: https://portalname.hexnodemdm.com/usergroup/usergroupID/#/

You can use that ID in your API call. Same goes for users, devices, and device groups.

Save