Forum Discussion

jwillis07's avatar
jwillis07
Advocate I
4 years ago

Query works in Power Query, but fails when loading into Power BI?

Good afternoon all,

Hoping you can help! I created the below code to call from the Tenable.io API which works perfectly in Power Query and I can see the results...

 

let

    URL1    = "https://cloud.tenable.com/vulns/export",
    Access  = "ACCESSKEY",
    Secret  = "SECRETKEY",
    Body    = "{""include_unlicensed"": false,""num_assets"": 5000}",
    Header  = "accessKey=" & Access & ";secretKey=" & Secret,
    
    Source1 = Json.Document(Web.Contents(URL1,
    
        [ Headers = [ #"X-ApiKeys" = Header ],
          Content = Text.ToBinary(Body)
        ]
    )),

    ExportUUID = Source1[export_uuid],

        URL2    = "https://cloud.tenable.com/vulns/export/" & Text.From(ExportUUID) & "/chunks/1",

     Source2 = Json.Document(Web.Contents(URL2,
    
        [ Headers = [ #"X-ApiKeys" = Header ]
        ]
     )),

    #"Converted to Table" = Table.FromList(Source2, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
    #"Expanded Column1" = Table.ExpandRecordColumn(#"Converted to Table", "Column1", {"asset", "output", "plugin", "port", "scan", "severity", "severity_id", "severity_default_id", "severity_modification_type", "first_found", "last_found", "state", "indexed"}, {"asset", "output", "plugin", "port", "scan", "severity", "severity_id", "severity_default_id", "severity_modification_type", "first_found", "last_found", "state", "indexed"}),
    #"Expanded asset" = Table.ExpandRecordColumn(#"Expanded Column1", "asset", {"agent_uuid", "hostname"}, {"agent_uuid", "hostname"}),
    #"Filtered Rows" = Table.SelectRows(#"Expanded asset", each ([severity_id] <> 0))

in
    #"Filtered Rows"

 

 

This works fine in Power Query and I can see the table and all the data in the preview window, however when I click "Close & Apply" to load the query into Power BI, I just get the following error:

 

"Query1
Web.Contents failed to get contents from 'https://cloud.tenable.com/vulns/export/3ac7472a-1166-4e81-8f21-c6367b5cf946/chunks/1' (400): Bad Request"
 
Is anyone able to shed some light on why this would be happening? If it works in Power Query, it should load into Power BI, right? I've never seen this before.
 
Any advice would be greatly appreciated!

 

 

 

 

 

3 Replies

  • Hi jwillis07 ,

     

    I'm not a tenable/API expert, but the first thing I'd do is remove any fields in your query that contain a nested record/table/binary etc.

    These are the cells that have a word as a yellow link in them (e.g. your [plugin], [port], and [scan] fields in the screenshot) and these can't be accepted by the data model.

     

    Pete

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi jwillis07 ,

     

    This means that the server returned an error. There may be an error message in the body of the HTTP response; if so, you can use fiddler to trace your HTTP traffic and see what the message is.

     

    Best Regards,

    Stephen Tao

     

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

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi jwillis07 ,


    Could you tell me if your problem has been solved?
    If it is, kindly Accept it as the solution. More people will benefit from it.
    Or you are still confused about it, please provide me with more details about your problem.


    Best Regards,
    Stephen Tao