Why am I getting a 403 error when making a POST request using tetpyclient?

Question:

Trying to make a POST request in Cisco’s Tetration API using their tetpyclient. I get a 200 response when using a get request, but 403 when making POST request with json filters for querying flows. Is my syntax for the json data incorrect or is there a syntax error in my python?

from tetpyclient import RestClient
import urllib3
import json
import requests
from datetime import datetime
from flask import *
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)

API_ENDPOINT = "https://"
restclient = RestClient(API_ENDPOINT, credentials_file = 'path/to/credentials.json', verify = False)
get = restclient.get("/flowsearch/metrics")
print (get.status_code) ##to test if api can be reached

req_payload = {"t0": "2020-08-01T09:00:00-0700",
               "t1": "2020-08-01T10:00:00-0700",
               "scopeName": "Default",
               "limit": 10,
               "filter": {                  
                  "type": "and",
                  "filters": [
                     {"type": "eq", "field": "src_address","value": "00.000.0.000" },
                     {"type": "eq", "field": "dst_address","value": "000.000.00.00" }
                   ]
}
}

resp = restclient.post('/flowsearch', json_body=json.dumps(req_payload))

print(resp.content)
print (resp.status_code)

if resp.status_code == 200:
   parsed_resp = json.loads(resp.content)
   print (json.dumps(parsed_resp, indent=4, sort_keys=True))

I appreciate any and allfeedback!
Here is link to tetration api docs: https://www.cisco.com/c/en/us/td/docs/security/workload_security/tetration-analytics/sw/config/b_Tetration_OpenAPI/m_flow-search.html

Asked By: Dani Major

||

Answers:

The HTTP 403 is a HTTP status code meaning access to the requested resource is forbidden for some reason

It looks like the credentials you are using are not allowed to call /flowsearch

Answered By: balderman