cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
394
Views
0
Helpful
1
Replies

DNAC API Create Report keeps returning HTTP 500

stcoppens
Level 1
Level 1

Hi!

I've been trying to create reports via the API so I can automate some data retrieval. However, I've attempted to do this by using:

- The built-in developer toolkit

- Postman

- Python scripts

Each returning "Http Error Code:500" with not much else to go on.

I'm assuming my error is because of some fault in my payload. I've copied the JSON request body from https://developer.cisco.com/docs/dna-center/#!create-or-schedule-a-report after filling in all the details in the form and adjusting the valuee/schedule where needed. I have also tested sending my payload as-is or as json.dumps(payload) with the request.

My script in short:

 
    url = f"https://{dnaURL}:443/dna/intent/api/v1/data/reports"
    payload = '''{
    "tags": [],
    "deliveries": [ {} ],
    "name": "API Test - Client Report",
    "schedule": {
        "type": "SCHEDULE_LATER",
        "timeZoneId": "Europe/Brussels",
        "scheduledServiceId": "b826f162-5115-49cd-9267-1f81b423178c",
        "dateTime": 1696949730
    },
    "view": {
        "fieldGroups": [
            {
                "fieldGroupDisplayName": "Client Details",
                "fieldGroupName": "client_details",
                "fields": [
                    {
                        "displayName": "MAC Address",
                        "name": "macAddress"
                    },
                    {
                        "displayName": "Connected Device Name",
                        "name": "connectedDeviceName"
                    },
                    {
                        "displayName": "Band",
                        "name": "frequency"
                    },
                    {
                        "displayName": "Last Location",
                        "name": "site"
                    },
                    {
                        "displayName": "SSID",
                        "name": "ssid"
                    }
                ]
            }
        ],
        "filters": [
            {
                "value": [
                    {
                        "value": "sample-global-site-id",
                        "displayValue": "Global"
                    }
                ],
                "displayName": "Location",
                "name": "Location",
                "type": "MULTI_SELECT_TREE"
            },
            {
                "value": [
                    {
                        "value": "Wireless",
                        "displayValue": "Wireless"
                    }
                ],
                "type": "SINGLE_SELECT_ARRAY",
                "name": "DeviceType",
                "displayName": "Device Type"
            },
            {
                "value": [
                    {
                        "value": "SSID_one",
                        "displayValue": "SSID_one"
                    },
                    {
                        "value": "SSID_two",
                        "displayValue": "SSID_two"
                    }
                ],
                "type": "MULTI_SELECT",
                "displayName": "SSID",
                "name": "SSID"
            },
            {
                "value": [
                    {
                        "value": "2.4",
                        "displayValue": "2.4"
                    },
                    {
                        "value": "5",
                        "displayValue": "5"
                    }
                ],
                "type": "MULTI_SELECT",
                "displayName": "Band",
                "name": "Band"
            },
            {
                "value": {
                    "timeRangeOption": "CUSTOM",
                    "startDateTime": 1696834800000,
                    "endDateTime": 1696863660000,
                    "timeZoneId": "Europe/Brussels"
                },
                "type": "TIME_RANGE",
                "name": "TimeRange",
                "displayName": "Time Range"
            }
        ],
        "format": {
            "formatType": "JSON",
            "name": "JSON"
        },
        "name": "Client Detail",
        "viewId": "e8e66b17-4aeb-4857-af81-f472023bb05e"
    },
    "dataCategory": "Client",
    "viewGroupId": "d7afe5c9-4941-4251-8bf5-0fb643e90847",
    "viewGroupVersion": "2.0.0"
}'''
   
    headers = {
        "Content-Type": "application/json",
        "Accept": "application/json",
        'x-auth-token':X_AUTH_TOKEN
    }
   
    # Attempt HTTP request
    r = requests.request('POST', url, headers=headers, data = json.dumps(payload), verify=False)

Could someone give me some advice what I'm doing wrong?

Thanks in advance!

 

1 Reply 1

marce1000
VIP
VIP

 

  - I got some error when using https://jsonlint.com/  , for your input ; you may want to run that too , 

 M.



-- Each morning when I wake up and look into the mirror I always say ' Why am I so brilliant ? '
    When the mirror will then always repond to me with ' The only thing that exceeds your brilliance is your beauty! '