How to import data using a POST API? Specifically …


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:

Screenshot 2024-04-08 at 2.58.53 PM.png

 



Source link

Leave a Comment