Thanks again. Look forward to seeing better improved documentation in the future.
Original Message:
Sent: Thu September 14, 2023 04:01 AM
From: Oktawian Powązka
Subject: REST API for uploading disconnected scan results
I'll take this into consideration for this doc update task...
------------------------------
Thank you,
Oktawian
Oktawian Powązka, L3 Support
IBM License Metric Tool
Original Message:
Sent: Wed September 13, 2023 10:39 AM
From: York Ly
Subject: REST API for uploading disconnected scan results
Thanks Oktawian, you are the best and life saver. I have spent over an hour trying to figure out these error messages below especially "The 'filename' parameter is not specified............." message. No idea why it kept failing with missing filename parameter even it was defined.
Then other errors just did not make sense to me. See below.
Unnecessary use of -X or --request, POST is already inferred.
* Could not resolve host: Source
* Closing connection 1
curl: (6) Could not resolve host: Source
Driving me crazy yesterday. Usually, providing a double quote such as "Data Source 2" would handle the spacing. The error should have indicated missing the "datasource_name" parameter instead of "filename" parameter.
====================
"success":false,"message":"The 'filename' parameter is not specified. Specify the parameter."}* Closing connection 0
* schannel: shutting down SSL/TLS connection with 192.168.0.182 port 9081
Note: Unnecessary use of -X or --request, POST is already inferred.
* Could not resolve host: Source
* Closing connection 1
curl: (6) Could not resolve host: Source
Note: Unnecessary use of -X or --request, POST is already inferred.
* Closing connection -1
curl: (3) URL using bad/illegal format or missing URL
===========
So I updated my curl statement with "Data%20Source%202" and it worked perfectly.
curl --insecure -v -H "Accept:application/json" -H "Token:e679f8777c87e5889fe9df54e8d8e6eb9a8263a4" -H "Content-Type:application/octet-stream" --data-binary "@D:/Downloads/LMT-DisconnectedScanner-windows-9.2.32.0-20230621-0049/output/202309122119-DESKTOP-US1K34G-4c4e2cde-87ff-49fc-8305-275d17a61913-1694553293.zip" -X POST "https://192.168.0.182:9081/api/sam/v2/scan_results_upload?datasource_name=Data%20Source%202&filename=202309122119-DESKTOP-US1K34G-4c4e2cde-87ff-49fc-8305-275d17a61913-1694553293.zip"
Note: Unnecessary use of -X or --request, POST is already inferred.
* Trying 192.168.0.182:9081...
* Connected to 192.168.0.182 (192.168.0.182) port 9081 (#0)
* schannel: disabled automatic use of client certificate
* schannel: using IP address, SNI is not supported by OS.
* ALPN: offers http/1.1
* ALPN: server did not agree on a protocol. Uses default.
* using HTTP/1.x
> POST /api/sam/v2/scan_results_upload?datasource_name=Data%20Source%202&filename=202309122119-DESKTOP-US1K34G-4c4e2cde-87ff-49fc-8305-275d17a61913-1694553293.zip HTTP/1.1
> Host: 192.168.0.182:9081
> User-Agent: curl/8.0.1
> Accept:application/json
> Token:e679f8777c87e5889fe9df54e8d8e6eb9a8263a4
> Content-Type:application/octet-stream
> Content-Length: 22636
>
* We are completely uploaded and fine
< HTTP/1.1 200 OK
< Strict-Transport-Security: max-age=31536000
< X-Frame-Options: SAMEORIGIN
< X-XSS-Protection: 1; mode=block
< X-Content-Type-Options: nosniff
< X-Download-Options: noopen
< X-Permitted-Cross-Domain-Policies: none
< Referrer-Policy: strict-origin-when-cross-origin
< Strict-Transport-Security: max-age=31536000
< Content-Language: en
< Expires: Fri, 01 Jan 1990 00:00:00 GMT
< Access-Control-Allow-Origin: *
< Content-Security-Policy: default-src 'self'; img-src 'self' data: ; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval' blob: ; script-src-elem 'self' 'unsafe-inline' data: ; font-src 'self' data: ;
< Content-Type: text/plain; charset=utf-8
< Cache-Control: private, no-store, no-cache, max-age=0, must-revalidate
< Content-Length: 78
< ETag: W/"a94a3e2e4ca9528ff7a8b5b8d629779b"
< Set-Cookie: _DSS_session=RDcxV3p1czdoUURhRjUxdU5QSWkwdFcreklndGpOWGpDNU91WFRucHlsNTVsT25oMWhFV1dBM0o4NEhJSTVZcGVhSXlJTHV6cGlWSnp6b0g0eWpHVy9mQ3JaUi9nMVI5UVpKdUhrMGNvdVZrWC8wcmZleUliSjdOeDRocE5XcmJidUJ4ektyVHBTTk92cy84c3lpaDRnPT0tLTY2U0VOQ25LT3RDT0I1ajBUTGpYekE9PQ%3D%3D--3515829e1362a7a85a6c69457bc914cf5a8b1322; path=/; secure; HttpOnly
< X-Request-Id: 3de37aee-5811-49f6-874d-8544f611485c
< X-Runtime: 0.187654
< Date: Wed, 13 Sep 2023 14:18:12 GMT
<
{"success":true,"message":"File with scan results was uploaded successfully."}* Connection #0 to host 192.168.0.182 left intact

Oktawian, as I mentioned early that documentation is very very important for everyone. Missing information can really cause a lot of pain and wasting human resources to diagnose the issue. Providing a very very details and good example how to do thing is extremely important for users. Providing a sample format or formula is a good start but it also needs the actual sample on how to use it and fill in the information such as this case. You know where the problem is, why not document such requirement/information.
I know there are a lot more REST API calls in the documentation which don't provide a good sample scenario how to use it or fill in the information. I recommend someone go through them and update the documents and provide some good real life examples so reader or user can easily understand and use it.
Thanks again for your quick response.
Have a look at this link below where it documented a syntax + a good example follow. That is what it should be included in ILMT document where it is needed to further clarify how to populate the information in the syntax.
https://www.ibm.com/docs/en/license-metric-tool?topic=certificate-step-1-creating-private-keys-certificates
Appreciated.
------------------------------
York Ly
Original Message:
Sent: Wed September 13, 2023 05:01 AM
From: Oktawian Powązka
Subject: REST API for uploading disconnected scan results
Hello York,
Following is a syntax for your case scenario:
curl --insecure -v -H "Accept:application/json" -H "Token:xxx" -H "Content-Type:application/octet-stream" --data-binary "@D:/Downloads/LMT-DisconnectedScanner-windows-9.2.32.0-20230621-0049/output/202309122119-DESKTOP-US1K34G-4c4e2cde-87ff-49fc-8305-275d17a61913-1694553293.zip" -X POST "https://192.168.0.182:9081/api/sam/v2/scan_results_upload?datasource_name=Data%20Source%202&filename=202309122119-DESKTOP-US1K34G-4c4e2cde-87ff-49fc-8305-275d17a61913-1694553293.zip"
Basically, If disconnected data source name contains a space it needs to be replaced by '%20' character.
I've requested a doc update...
------------------------------
Thank you,
Oktawian
Oktawian Powązka, L3 Support
IBM License Metric Tool
Original Message:
Sent: Tue September 12, 2023 06:24 PM
From: York Ly
Subject: REST API for uploading disconnected scan results
Hi ILMT support team, using the REST API call to upload the disconnected scanner results described in this link below really needs a good example of what REST API is really coded.
At the bottom of this page, it gives you a sample format. As a reader or user attempting to follow that sample format, it always does not help much trying to figure what exactly the information needs to be filled in.,
curl --insecure -v -H "Accept:application/json" -H "Token:<token>" -H "Content-Type:application/octet-stream" --data-binary "@<path_to_file><file_name>" -X POST "https://<host>:<port>/api/sam/v2/scan_results_upload? datasource_name=<data_source_name>&&filename=<file_name>"
I have been to figure out why mine curl statement does not work after trying different way to understand where or how the information should be filled in.
curl --insecure -v -H "Accept:application/json" -H "Token:e679f8777c87e5889fe9df54e8d8e6eb9a8263a4" -H "Content-Type:application/octet-stream" --data-binary "@D:/Downloads/LMT-DisconnectedScanner-windows-9.2.32.0-20230621-0049/output/202309122119-DESKTOP-US1K34G-4c4e2cde-87ff-49fc-8305-275d17a61913-1694553293.zip" -X POST "https://192.168.0.182:9081/api/sam/v2/scan_results_upload?datasource_name="Data Source 2"&&filename=202309122119-DESKTOP-US1K34G-4c4e2cde-87ff-49fc-8305-275d17a61913-1694553293.zip"
Kept getting this error:
Note: Unnecessary use of -X or --request, POST is already inferred.
* Trying 192.168.0.182:9081...
* Connected to 192.168.0.182 (192.168.0.182) port 9081 (#0)
* schannel: disabled automatic use of client certificate
* schannel: using IP address, SNI is not supported by OS.
* ALPN: offers http/1.1
* ALPN: server did not agree on a protocol. Uses default.
* using HTTP/1.x
> POST /api/sam/v2/scan_results_upload?datasource_name=Data HTTP/1.1
> Host: 192.168.0.182:9081
> User-Agent: curl/8.0.1
> Accept:application/json
> Token:e679f8777c87e5889fe9df54e8d8e6eb9a8263a4
> Content-Type:application/octet-stream
> Content-Length: 22636
>
* We are completely uploaded and fine
< HTTP/1.1 400 Bad Request
< Strict-Transport-Security: max-age=31536000
< X-Frame-Options: SAMEORIGIN
< X-XSS-Protection: 1; mode=block
< X-Content-Type-Options: nosniff
< X-Download-Options: noopen
< X-Permitted-Cross-Domain-Policies: none
< Referrer-Policy: strict-origin-when-cross-origin
< Strict-Transport-Security: max-age=31536000
< Content-Language: en
< Expires: Fri, 01 Jan 1990 00:00:00 GMT
< Access-Control-Allow-Origin: *
< Content-Security-Policy: default-src 'self'; img-src 'self' data: ; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval' blob: ; script-src-elem 'self' 'unsafe-inline' data: ; font-src 'self' data: ;
< Content-Type: text/plain; charset=utf-8
< Cache-Control: private, no-store, no-cache, max-age=0, must-revalidate
< Content-Length: 95
< Set-Cookie: _DSS_session=UHBnbDFvVmZKMXUvLzNQTkUxSCs5amFzNW5oaE51cG4yVEJ3ZitlNGIxOEM5d09Pd1Qzb01jc3BBTTVtRVlVVkxrd04xalFGUlR6dFRxMnJpa0xOSVcycW5wc3h0Q3dTNk9jcjNlbnBsZkV0ZHRBS0QyKzJzNDVvNDBId0laQzBIMVBiWnRNWURuN0thajFsbG5heENBPT0tLUtEMjhNZEYzYk9xM2RwdjMyeTdYN2c9PQ%3D%3D--1702c1dbe2782933bbef9e4cb256da9597c618b7; path=/; secure; HttpOnly
< X-Request-Id: 8a15d003-0df9-4592-aa25-3a4ad9c69238
< X-Runtime: 0.060900
< Connection: Close
< Date: Tue, 12 Sep 2023 22:20:01 GMT
<
{"success":false,"message":"The 'filename' parameter is not specified. Specify the parameter."}* Closing connection 0
* schannel: shutting down SSL/TLS connection with 192.168.0.182 port 9081
Note: Unnecessary use of -X or --request, POST is already inferred.
* Could not resolve host: Source
* Closing connection 1
curl: (6) Could not resolve host: Source
Note: Unnecessary use of -X or --request, POST is already inferred.
* Closing connection -1
curl: (3) URL using bad/illegal format or missing URL
So please using my sample curl statement above and help me to fill in properly and make it works.
By the way, in any of the documentation related to REST API call, please provide a real life sample instead of just giving a format. Provide a sample format is always a good to start but giving a real scenario of what it should be filled in, it always helps for user to understand how the information should be populated.
Thanks and look forward to hearing good news from you to get my statement working.
My ILMT server is Linux and Windows disconnected scanner installed on Windows machine. Trying to using curl to upload the scanner result package back to my disconnected scanner data source on Linux. Hope this helps.
REST API for uploading disconnected scan results
Ibm | remove preview |
| REST API for uploading disconnected scan results | 9.2.30 Available from 9.2.30. You use the POST operation on the /api/sam/v2/scan_results_upload element to upload results of the disconnected scans to the disconnected data source. The results are provided in the request body in the binary form. | View this on Ibm > |
|
|
------------------------------
York Ly
------------------------------