As of Velocity 5.0, there is no public API to request resource discovery. This API will be added in future versions.
It is possible to automate discovery in a fashion similar to your approach - by making request to the endpoint used by Web UI. However, it is a fragile approach, as it basically means relying on implementation details which may (and will) change in the future.
Below are details on how to accomplish that. I will use `curl` in examples, but they can easily be mapped into iTest actions. Replace `velocity.example.com` as needed.
1. Log in and obtain `JSESSIONID` and `user_token`.
curl 'https://velocity.example.com/velocity/login.loginform' -H 'X-Requested-With: XMLHttpRequest' --data 'username=my_username&password=my_password&t%3Aformdata=RKIANTvJ3Ugm2L20c%2B7jeEPcZB0%3D%3AH4sIAAAAAAAAAJWQMUvDUBCAr0WlGJDa4uTiUNd0sYsudhGHoELQwe0luaRPkvee7y5NXFz9F%2F4CcXbv4OZ%2F8Ae4OjmYNBSHiOB08HHH93FPH7BeDGHb04lUh0KFM23nIs2RLBxrm7jCiHCGLguDxPZu4obaYiqDamZGK1RM7qmMIlSjC6tDJPLzIJNEUqvrh71hufuy0YWOB06oFVudnokMGQbejZiLcSpUMvbZSpUclYbBaQqu6oKiD1tNVk5oVXVWNU3%2BbAoEoTsNKihCPpGYRiMfOTf7lwvnfef1qxVyC%2FfQqcW9leNX6%2FS%2F1tYrFs%2FRQfz5%2BNYFKM2PwwiiQtuI6pC1KmMF2iv1Rq8YQL%2FBLDPUcUzIy1tg2KzR%2BRJ9A%2BMzFhzWAQAA&t%3Azoneid=loginZone&timeOffset=0'
Change `my_username` and `my_password` to actual username/password. Store `JSESSIONID` and `user_token` cookies, returned within `Set-Cookie` headers into variables. I will refer to them as ${sessionId} and ${token} in the next step.
2. Request resource discovery. Parameters here are: ${resourceId}, ${sessionId}, ${token}
curl 'https://velocity.example.com/velocity/inventory/resource.discoverybutton/${resourceId}?t:ac=${resourceId}' -H 'Cookie: JSESSIONID=${sessionId}; user_token=${token}' -H 'X-Requested-With: XMLHttpRequest' --data 't%3Azoneid=discoveryStartedZone'
The above steps could be executed via iTest using the REST session. Very cool. Thanks for the suggestion, and yes, this should only be a stop-gap solution as it is not via the documented API.
17 People are following this question.