Tejas Kore
Board Regular
- Joined
- Nov 2, 2017
- Messages
- 72
- Office Version
- 365
- Platform
- Windows
Hello Friends,
I am trying to fetch data from one of our vendor's site(https://developer.tenable.com/reference#exports-vulns-request-export) using API. I saw the api documentation but there weren't any examples using VBA. Here is a code snippet from python:
Here is my VBA code:
I need help here '--->.
I tried to print the response. It says 'obj.error --> Unsupported Media Type'. Basically I am trying to apply filters and fetch data. It would be great if anyone could let me know the mistake I am making.
Notes: 1. Using ParseJSON function to parse the JSON string received ('Excel VBA: Parse JSON, Easily).
2. last_found is UNIX time.
I am trying to fetch data from one of our vendor's site(https://developer.tenable.com/reference#exports-vulns-request-export) using API. I saw the api documentation but there weren't any examples using VBA. Here is a code snippet from python:
Code:
import requests
url = "https://cloud.tenable.com/vulns/export"
payload = {"filters": {
"tag.<category>": ["tag.CompanyName External Assets: IP"],
"last_found": 1625570746
}}
headers = {
"Accept": "application/json",
"Content-Type": "application/json",
"X-ApiKeys": "" #Cannot disclose publicly
}
response = requests.request("POST", url, json=payload, headers=headers)
print(response.text)
Here is my VBA code:
VBA Code:
Sub authenticated_test()
Dim req As MSXML2.ServerXMLHTTP60
Dim JsonString As String
Dim dic As Variant
Dim liveURL As String, paperURL As String
Dim acc_header_name, acc_header_value, secret_header_name, secret_key As String
Set req = New MSXML2.ServerXMLHTTP60
acc_header_name = "Accept"
acc_header_value = "application/json"
secret_header_name = "X-ApiKeys"
secret_key = "" 'Cannot disclose the key on public
liveURL = "https://cloud.tenable.com"
paperURL = "https://cloud.tenable.com/vulns/export"
req.Open "POST", paperURL, False
req.setRequestHeader acc_header_name, acc_header_value
req.setRequestHeader secret_header_name, secret_key
req.send ["filters", "tag.<category>", ["tag.CompanyName External Assets: IP"], "last_found", 1625570746] '---> Need help here
'Debug.Print req.responseText
Set dic = ParseJSON(req.responseText)
Debug.Print ListPaths(dic)
End Sub
I need help here '--->.
I tried to print the response. It says 'obj.error --> Unsupported Media Type'. Basically I am trying to apply filters and fetch data. It would be great if anyone could let me know the mistake I am making.
Notes: 1. Using ParseJSON function to parse the JSON string received ('Excel VBA: Parse JSON, Easily).
2. last_found is UNIX time.