Thank you
Hello @david_smith
can you share the same document to me also.
Sent!
@david_smith, Iād like a copy as well if available. Thanks in advance
Hello David,
I would like to query all hosts with their hostnames to match them with our asset database. Unfortunately, no structure is specified in the documentation. How exactly does the query have to look like if I want to find out host names and agent status.
Here is an example query
query MyQuery {
organization(id: "<ORG-ID-HERE>") {
assets(first: 10000) {
edges {
node {
agent {
id
agentSemanticVersion
agentStatus
}
host {
hostNames {
name
}
}
}
cursor
}
}
}
}
Note you can only poll for up to 10000 assets at a time, if you happen to have more than 10000 you need to use the cursor to step through the results.
Whatever string is returned from the cursor needs to be inputted into the subsequent query like so
query MyQuery {
organization(id: "<ORG-ID-HERE>") {
assets(first: 10000, after: "<CURSOR-VALUE-HERE>") {
edges {
node {
agent {
id
agentSemanticVersion
agentStatus
}
host {
hostNames {
name
}
}
}
cursor
}
}
}
}
This would return the next 10000, then the new cursor would return the next 10000 and so on.
David
Hi David,
thank you for your help but i get an Error:
Validation error of type FieldUndefined: Field ābootstrapā in type āAssetā is undefined @ 'organization/assets/edges/node/bootstrap
if I Query the __schema/types i get a long list, but bootstrap is not an entry in it.
Update:
today i talked with Ryan. He helped me with finding the correct Query:
query($orgId: String!){ organization(id:
$orgId) {
assets(first: 10000) {
edges {
node {
agent{
agentStatus
agentSemanticVersion
id
}
host{
hostNames{
name
}
}
}
cursor
}
}
}
}
Thanks for updating, I updated my post to reflect that so no one visiting from the future gets confused, I didnāt realize we had not exposed the bootstrap via the Graphql Preview API. We have a backend for querying and mutations which is a superset of what is currently available via the Public API
David
@david_smith - Can I also get the preview docs? Iāve been looking all over the place for a way to pull the asset information out of the Data Collection Management view without using the [Export to CSV] option.
Thanks!
@david_smith I am also looking for a way to retrieve all assets at once using call. I would love to get my hand on this documentation as well
Sent your way!
Hi David,
I followed the documentation but for some reason I got the following error:
{āerrorsā:[{āmessageā:āUnable to validate requestā}]}
Here is my code:
headers = {āx-api-keyā: API_KEY, āContent-Typeā: āapplication/jsonā, āAccept-Versionā: ākratosā }
url = āhttps://us.api.insight.rapid7.com/graphqlā
req = requests.post(url, headers=headers, json={āqueryā: query})
print(req.status_code)
print(req.text)
Hi @tnguyen5 how are you calling this? Via Python or something else?
Yes, I am using Python
Can you confirm you can run a query successfully using a Graphql client such as Altair?
Hereās a simply query I just ran
query MyQuery {
organization(id: "OrgID") {
assets(first: 10) {
edges {
node {
id
}
}
}
}
}
making sure to set the headers correctly
@david_smith , IĀ“d be pleased you if you send me the documentation. Thanks
Sent!
@david_smith Iād like to take a look at this as well. Would you be able to send this to me as well?
Iāve same request : Using a CURL cmd line (in a Powershellscript) to get all my assets.
Have you find how to ?