Forum Discussion

bavarian_bear's avatar
bavarian_bear
New Member
2 years ago

How to import data using a POST API? Specifically from Nessus Tenable endpoint

Hi all! Having the darndest time trying to get data from this API endpoint into Power BI:

https://developer.tenable.com/reference/vulnerabilities-import-v2

 

Searched far and wide, and seems the consensus on this forum is to use a third party tool like Postman but was hoping I could get around it by:

 

  1. Setting up a parameter function in Power Query
  2. Setting up an a subsequent query referencing that parameter to pull in the data

If anyone has any ideas, would love to hear it. Here are my queries:

 

Parameter:

 

let
ImportVulnerabilityData = (apiKey as text, data as text) =>
let
url = "https://cloud.tenable.com/vulnerability-import/v2",
headers = [
#"X-ApiKeys" = apiKey,
#"Content-Type" = "application/json"
],
response = Web.Contents(url, [
Headers=headers,
Content=Text.ToBinary(data)
]),
jsonResponse = Json.Document(response)
in
jsonResponse
in
ImportVulnerabilityData

 

 

Data:

 

let
Source = ImportVulnerabilityData,

apiKey = "accessKey=123;secretKey=321",

importedData = Source(apiKey, null),

dataTable = Table.FromList(importedData, Record.FieldValues, {})
in
dataTable

 

 


And my error message, not sure why Power BI can't see the parameter:

 

2 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    "ImportVulnerabilityData" is not the name of one of your queries. Your Source row in your "Data" query is therefore failing as it can't find a query of that name.

     

    I think what you intended to do was:

    let
    apiKey = "accessKey=123;secretKey=321",
    
    importedData = #"POST API"(apiKey, null),
    
    dataTable = Table.FromList(importedData, Record.FieldValues, {})
    in
    dataTable

     

    Also rename your function query to be a name without spaces, maybe something like fn_PostAPI.  Just makes calling it easier.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi, bavarian_bear 

    The error you're experiencing may be due to how the parameters are passed or how the API response is handled. Make sure that the variables passed into the function are properly formatted. The API key should match the expected format required by the Tenable API. Make sure that all required headers and parameters are specified correctly. Pay special attention to any required headers, HTTP methods, and URL parameters. You can refer to the Tenable API documentation:

    Import vulnerabilities v2 (tenable.com)

     

    How to Get Your Question Answered Quickly 

    Best Regards

    Yongkang Hua

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.