Unable to reach InsightVM API

Hello Everyone,
I am trying to connect to the API to grab information of all the active hosts. I have created both an organization key and a personal api key and tried to connect to https://{region}.api.insight.rapid7.com/vm/ where I get a successful connection but no information. Additionally, it appears the endpoint I want to connect to https://{region}.api.insight.rapid7.com/vm/3/sites{id}/assets is producing a 404 error. I am curious if this is due to my current permissions on rapid7 or any other reasons. Thanks!

I think you’re mixing up the two separate APIs for InsightVM. There is v3 (Console) and v4 (Cloud)

v3 uses the console URL for the endpoint and basic auth

v4 uses the platform URL for the endpoint and API token

Both sets of documentation that I linked to above should spell out the endpoints and authorization types in the Overview section.

Thanks John, I am using the v4 API now but am running into an error still. I want to grab the assets from a specific site. This is the endpoint I am currently trying https://{region}.api.insight.rapid7.com/vm/v4/integration/sites/{id}/assets. Also, when I am trying to grab all assets using https://{region}.api.insight.rapid7.com/vm/v4/integration/assets I receive a 401 error. Thanks Again!

What are you using to hit these API endpoints? Are you using an application like Postman or are you using a Python script? Or are you just doing a direct curl command or something?

If you could show some more screenshots (sanitized of course) of how you’re trying to fetch the data that might help. The 401 error is basically saying it’s unauthorized so either the API Token is not being passed properly or the account that was used to create the API token did not have valid permissions. Given that you’re just trying to GET data I assume the API token is not being passed properly.

Hi John, I am using a Python Script. For now I am just trying to just test out the connection and figure out the correct endpoint so I can get all the assets from a certain site. From the above documentation you sent, when working with sites, you have to send a post call.
This is what I am doing and getting this response.

Thanks so much for your help!

1 Like

Well you shouldn’t need the 443 in the URL but when I add that in it actually gives me a 404 error, not a 401 error. Everything else looks fine as far as I can tell. I don’t think it’s a certificate issue but if you don’t have them loaded then maybe it’s possible. You could add this in to your code as well and see if it helps.

import urllib3

### Add this into the response portion in the parenthesis
, verify=False
1 Like

Hi John, thanks for your help. This is where I am at now,
I am still getting a 401 error. Also, if you have any insight on if there is a specific endpoint I should be using to get the assets in site 1 that would be amazing.



So you can’t just call out a site_id in the endpoint like that. What you would do is use the base endpoint and then pass a payload with some JSON referring to what you’re looking for. Similar to using the Query Builder within the tool.

url = "https://us2.api.insight.rapid7.com/vm/v4/integration/assets"

payload = json.dumps({
  "asset": "sites IN ['siteName1', 'siteName2']"
headers = {
  'X-Api-Key': api_key,
  'Content-Type': 'application/json'

response = requests.request("POST", url, headers=headers, data=payload)