Unsolved
1 Message
0
882
July 31st, 2022 16:00
WMS API - Search for Workstation by name
Has anyone figured out how to do an API search for a workstation by its name? The only thing I have figured out is to iterate thru all the deviceID pages and search for the name. Which is really inefficient.
My PHP / CURL Code - (trying to figure out how to get this to PowerShell as well)
$workstation = $_GET['workstation'];
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https:// /wms-api/wms/v1/SessionService/Sessions',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_HEADER => true,
CURLOPT_ENCODING => '',
CURLOPT_TIMEOUT => 0,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{"UserName":"User","Password":"Password"}',
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json'
),
));
$authresponse = curl_exec($curl);
// Process response and pull token to variable
$header_size = curl_getinfo($curl, CURLINFO_HEADER_SIZE);
$header = substr($authresponse, 0, $header_size);
$headers = explode('X-Auth-Token:', $header, 2);
$token = explode('Cache-Control:', $headers[1], 2);
$machinefound = "false";
$deviceinfo = "";
for($page = 1; $page <= 1000 ;$page++){
// Find device id by pulling device list
curl_setopt_array($curl, array(
CURLOPT_URL => 'https:// /wms-api/wms/v1/Systems?page=' . $page,
CURLOPT_HEADER => false,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_SSL_VERIFYHOST => false,
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_HTTPHEADER => array(
'X-Auth-Token: ' . $token[0]
),
));
$sysresponse = curl_exec($curl);
// Process response and pull the $device
$devices = json_decode($sysresponse,true);
array_filter($devices["Members"], function ($var) use ($workstation) {
foreach($var as $device){
if (stripos($var['Oem']['SystemName'],$workstation) !== false){
global $deviceinfo;
$deviceinfo = $var['@odata.id'];
$page = 10001;
return true;
} else {
return false;
}
};
});
if($deviceinfo != ""){
break;
}
}
// Get the device information
curl_setopt_array($curl, array(
CURLOPT_URL => 'https:// /wms-api' . $deviceinfo,
CURLOPT_HEADER => true,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_SSL_VERIFYHOST => false,
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_HTTPHEADER => array(
'X-Auth-Token: ' . $token[0]
),
));
$deviceresponse = curl_exec($curl);
// Process device info and return the json results
$header_size = curl_getinfo($curl, CURLINFO_HEADER_SIZE);
$header = substr($deviceresponse, 0, $header_size);
$device = json_decode(substr($deviceresponse, $header_size),true);
ODell Wyzam
8 Posts
1
August 3rd, 2022 10:00
It gets even worse than that. The list of all of your devices in the background is ordered by the last check in date/time. I have been unable to pull a complete list of devices as you end up with duplicates and missing devices as the list re-orders itself as devices check in.
It may be easier if you have less devices or a longer check in interval but I have 250+ pages and haven't been able to complete list since you have to wait so long between calls to avoid getting timed out.
mdmann
11 Posts
0
August 19th, 2022 20:00
I'd like to know where you got the information to even create this code. I've been trying to find clear information about using the WMS API with absolutely no luck. And now, it seems as if they are using something with Service Now, and I have no idea how this is supposed to work. I am seriously BEYOND FRUSTRATED with Dell and this WMS API. It seems they are intentionally making it as difficult to use as possible.
mdmann
11 Posts
0
August 21st, 2022 05:00
Could you tell me how you have things configured such that the X-Auth-Token is actually returned? When I attempt to run your code on our on premises server v3.3.1 with API enabled, I get the following response:
"The authentication token header is missing in the request.","MessageArgs":["POST","X-Auth-Token"],"RelatedProperties":["#/"],"Resolution":"Please sign-in with URL /wms/v1/SessionService/Sessions"
But that is the url I am using (after the "wms-api" part). It's as if something is not configured properly, but I can not tell what.
mdmann
11 Posts
0
August 23rd, 2022 18:00
If you could help me figure out how to get this code to even return an X-Auth-Token, I would be willing to help you get it to work in Powershell, as I have an interest in that as well. But I simply can not get this code to work. I get the feeling there is some key component I am missing in the setup *on the server*, but without clearer documentation from Dell, I simply can't figure it out. I'm on WMS v3.3.1, and I have WMS API enabled. I don't have anything configured under "External App Services," but even if I do, I can't actually activate it and don't know what is supposed to be done with the API key and secret displayed, if anything. PLEASE help me understand how this feature is supposed to be used.
HansjoergB
4 Posts
0
October 10th, 2022 01:00
Hey @ODell Wyzam , mayn thanks for this post.
I was going crazy while reading the list of all my devices from WMS-API and always:
1. found duplicates which I wasn't able to explain
2.some are missing
Analyzing it, I found that there are mainly "blocks" of devices in my list which are duplicated. But each export the duplicates changed. So I would agree and confirm your root cause is the bad order after check-in time. Oh dear.
Question: Is there a way to change order of the device-list output to SystemName ?
Thanks,
Hansjoerg
ODell Wyzam
8 Posts
0
October 11th, 2022 06:00
Not that I can find.
There is a pro support case open on it that was recently passed up to engineering.
I'll respond here with an update when I have one.
HansjoergB
4 Posts
0
October 17th, 2022 05:00
This is probably my DELL Support Ticket
Thanks for following up.
Hansjoerg