aldn-bnk Posted April 17, 2023 Share Posted April 17, 2023 Hi Team, I created an queries with goal is get the devices detail information base on their serial number. I saw the guidance from this KB https://fwkb.atlassian.net/wiki/spaces/KB/pages/4328035/RESTful+API#RESTfulAPI-BreakingdowntheJSON%2FResults Then I tried to pass the variable from RestAPI to the queries but the result still failed, like the parameter doesn't success passed to the queries. Is it any same case like me? Thanks Link to comment Share on other sites More sharing options...
AnEngelsen Posted April 17, 2023 Share Posted April 17, 2023 @aldn-bnk What are you trying to achieve using the FileWave API? For example, Are you trying to access the results of an inventory query? Or are you trying to access a specific piece of information about a client (based on the device serial number)? Link to comment Share on other sites More sharing options...
aldn-bnk Posted April 18, 2023 Author Share Posted April 18, 2023 6 hours ago, AnEngelsen said: @aldn-bnk What are you trying to achieve using the FileWave API? For example, Are you trying to access the results of an inventory query? Or are you trying to access a specific piece of information about a client (based on the device serial number)? Hi @AnEngelsen, My goals is to access a specific piece of information about a client based on the device serial number. Because on the KB page, there is no information or sample if I want to search the device by serial number Link to comment Share on other sites More sharing options...
AnEngelsen Posted April 19, 2023 Share Posted April 19, 2023 Based on what I'm seeing in the API docs (https://FileWaveServer_URLGoesHere/api/doc/), the FileWave API requires you to provide the ClientID or DeviceID to perform a device lookup. (You cannot pass the serial number as the unique identifier.) That said, you might be able to build an inventory query that contains that device serial number and the piece of information you want to capture. Then you would use the API to reference the inventory query (and the resulting inventory data): https://fwkb.atlassian.net/wiki/spaces/KB/pages/4328035/RESTful+API#RESTfulAPI-Commands 1 Link to comment Share on other sites More sharing options...
Moderators Sean Posted April 20, 2023 Moderators Share Posted April 20, 2023 This isn't entirely correct. FileWave has two different APIs Command line - has existed for years and may run queries Web - Created when we introduced the Web Admin and may do much more The Web Admin API relies upon Client ID when attempting to reference devices directly, but as suggested if you build out a query in advance you may then interrogate the query for details. You may even use this API to create a query The command line API on the other hand can be provided a query and return results without it actually creating a new query in the database. As such, you can build out anything you can akin to using the FileWave Central (Admin) App Inventory Query and the result should be posted back. Here is an example query using the Command Line API: #!/bin/zsh query='{"criteria":{"column":"serial_number","component":"Client","operator":"is","qualifier":'\"$serial_number\"'},"fields":[{"column":"device_name","component":"Client"},{"column":"type","component":"OperatingSystem"}],"main_component":"DesktopClient"}' curl -k -s -H "Authorization: $auth" https://$server_dns:20443/inv/api/v1/query_result/ --data $query -H "Content-Type: application/json" This example will report the Device Name and OS Type for the defined serial number and is the same as the following (I've put an exact serial_number in the GUI example to make it easier to see: If you don't know the component names and types, then use the Web Admin API Docs to find them out. Build out a query, save it then use the API doc to report all queries: Find your query in the list (if you just created it, it will be at the bottom), e.g. { "id": 253, "name": "OS Type", "favorite": true, "group": null, "version": 4 } Then use the API Doc again to examine the query: { "criteria": { "column": "serial_number", "component": "Client", "operator": "is", "qualifier": "C02Z90WDLVDQ" }, "favorite": true, "fields": [ { "column": "type", "component": "OperatingSystem" } ], "main_component": "DesktopClient", "name": "OS Type", "id": 253, "version": 4, "group": 0 } Note the URL paths between Web Admin and Command Line differ. Hopefully that is enough information for you to achieve your goal. 2 Link to comment Share on other sites More sharing options...
Daniel S. Posted April 20, 2023 Share Posted April 20, 2023 Can I use the POST method to create queries via the API? Link to comment Share on other sites More sharing options...
Daniel S. Posted April 20, 2023 Share Posted April 20, 2023 N/M... I figured out what I was doing wrong... When using existing JSON from an existing Query from one server, you can POST queries to a new/fresh/test server, but I had to REMOVE the id: & group: and set the version: to 1 1 Link to comment Share on other sites More sharing options...
Moderators Sean Posted April 25, 2023 Moderators Share Posted April 25, 2023 For the query, you need not include version either, this will be auto generated during creation. Link to comment Share on other sites More sharing options...
aldn-bnk Posted May 3, 2023 Author Share Posted May 3, 2023 On 4/20/2023 at 7:41 PM, Sean said: This isn't entirely correct. FileWave has two different APIs Command line - has existed for years and may run queries Web - Created when we introduced the Web Admin and may do much more The Web Admin API relies upon Client ID when attempting to reference devices directly, but as suggested if you build out a query in advance you may then interrogate the query for details. You may even use this API to create a query The command line API on the other hand can be provided a query and return results without it actually creating a new query in the database. As such, you can build out anything you can akin to using the FileWave Central (Admin) App Inventory Query and the result should be posted back. Here is an example query using the Command Line API: #!/bin/zsh query='{"criteria":{"column":"serial_number","component":"Client","operator":"is","qualifier":'\"$serial_number\"'},"fields":[{"column":"device_name","component":"Client"},{"column":"type","component":"OperatingSystem"}],"main_component":"DesktopClient"}' curl -k -s -H "Authorization: $auth" https://$server_dns:20443/inv/api/v1/query_result/ --data $query -H "Content-Type: application/json" This example will report the Device Name and OS Type for the defined serial number and is the same as the following (I've put an exact serial_number in the GUI example to make it easier to see: If you don't know the component names and types, then use the Web Admin API Docs to find them out. Build out a query, save it then use the API doc to report all queries: Find your query in the list (if you just created it, it will be at the bottom), e.g. { "id": 253, "name": "OS Type", "favorite": true, "group": null, "version": 4 } Then use the API Doc again to examine the query: { "criteria": { "column": "serial_number", "component": "Client", "operator": "is", "qualifier": "C02Z90WDLVDQ" }, "favorite": true, "fields": [ { "column": "type", "component": "OperatingSystem" } ], "main_component": "DesktopClient", "name": "OS Type", "id": 253, "version": 4, "group": 0 } Note the URL paths between Web Admin and Command Line differ. Hopefully that is enough information for you to achieve your goal. Hi @Sean, Thank you so much for your kindly clear information and advise. Your advise is what I want to achieve it. Now I can use API for searching Device using S/N. Thanks 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now