- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-27-2023 08:25 AM
Hi,
I am trying the following API call from pything and the responce i get is below, can any one tell me why it is failling, it does give a 202 reponce code with the message "message" : "The request has been accepted for execution" but then it comes back with the following.
Thank you
{
"bapiKey": "98a8-aa5e-40cb-b90b",
"bapiName": "Assign Device To Site",
"bapiExecutionId": "79cf4eed-081f-4f24-a157-f7ba5764e7c4",
"startTime": "Mon Nov 27 16:15:58 UTC 2023",
"startTimeEpoch": 1701101758666,
"endTime": "Mon Nov 27 16:15:58 UTC 2023",
"endTimeEpoch": 1701101758697,
"timeDuration": 31,
"status": "FAILURE",
"bapiError": "{\"status\":\"False\"}",
"runtimeInstanceId": "DNACP_Runtime_907770e3-8857-435b-8725-0bfd5c8eaccb"
}
Solved! Go to Solution.
- Labels:
-
Cisco DNA
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-27-2023 09:24 AM
Awesome, Yes if you are specifying the json parameter when making the POST request, you don't need to explicitly convert the payload to JSON yourself using json.dumps().
Connect with me https://bigevilbeard.github.io

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-27-2023 08:41 AM
@AaronStreet odd message, the 202 status means "I've accepted this request and will process it in the future, but I'm not committing to provide the outcome status immediately."
Some key things to note from your error
- status: "FAILURE" - overall status of the API call is failure
- bapiError: "{\\"status\\":\\"False\\"}" - raw error returned by the API. It is returning a JSON object with status set to "False", indicating there was an error in processing your request
Can you share the code you are using and the API endpoint/url?
Hope this helps.
Connect with me https://bigevilbeard.github.io
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-27-2023 09:10 AM
Hi, see below, the DNAC and Token variables work ok for other API calls in the same script such as "get sites", the site variable is a building site id in formate "349f9ffc-8d46-xxxx-xxxx-xxxxxxxxxx2d", and the device IP is the managment IP.
Under the GUI i can see the device in question is showing and "unasigned"
the output of the print statments are these (replaced some parts with xx)
<sitename> 89xxxxxx-xxxx-xxxx-xxxx-1e164cf904d4 10.80.x.x
dnac-eu.corp.comt
{"device": [{"ip": "10.80.x.x"}]}
{
"executionId" : "f7224742-5ed0-45ef-9426-0a4bd6c59195",
"executionStatusUrl" : "/dna/platform/management/business-api/v1/execution-status/f7224742-5ed0-45ef-9426-0a4bd6c59195",
"message" : "The request has been accepted for execution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-27-2023 09:18 AM
Hi,
I think it was that i dont need the data=json.dumps(device_list), as i already have it in json format.
commenting out this seems to fix it, sorry and thank you for taking the time to look at this for me.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-27-2023 09:24 AM
Awesome, Yes if you are specifying the json parameter when making the POST request, you don't need to explicitly convert the payload to JSON yourself using json.dumps().
Connect with me https://bigevilbeard.github.io
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-27-2023 08:43 AM
here is the correct syntax to be used :
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-27-2023 09:44 AM
Thank you for your help, a slightly different question, when creating the script in 2.3.5.4 the responce to gettin list of network devices "https://{}/api/v1/network-device?location=null&family=Switches and Hubs&series=Cisco Catalyst 9300 Series Switches".format(dnac['host']" the location and locationname always comes back as "null" even when the device is assigned to a site/floor?
has any one else seen this?
