cancel
Showing results forĀ 
Search instead forĀ 
Did you mean:Ā 
cancel
1538
Views
15
Helpful
8
Replies

Retrieve all wireless profiles via DNAC API

Cedric Metzger
Level 1
Level 1

For a specific usecase, I need to get all wireless profiles from DNAC via API. The documentation (https://developer.cisco.com/docs/dna-center/#!get-wireless-profile) says that the /dna/intent/api/v1/wireless/profile should "Get either one or all the wireless network profiles if no name is provided for network-profile"

 

But when I issue the API call with an empty value for "profileName" I always get a "undefined" as response. Following you can see my test from DNACs toolkit page. I get the same result with postman.

 

Screenshot 2022-02-24 at 18.34.52.png

Test Summary for "profileName" values:

- nothing submitted: "undefined"

- "asdf" submitted: "Profile Not Found"

- valid profile name submitted: Profile gets returned

 

Has anybody an idea, which value I need to enter, to get all wireless profiles returned?

1 Accepted Solution

Accepted Solutions

Cedric Metzger
Level 1
Level 1

After a lot of trial and error, I figured out, that for some reason my lab-DNAC doesn't like the /dna/intent/api/v1/wireless/profile call. If I do it on customers DNAC or on a dCloud DNAC the call works perfectly fine.

Thanks to everybody who tried helping me.

View solution in original post

8 Replies 8

korey_oehlers
Level 1
Level 1

Hey Cedric,

 

Have you tried deleting the query param, and just using /dna/intent/api/v1/wireless/profile with no query?

 

I can't test right now unfortunately, so not sure if this works. 

Hi Korey,

Yes i tried this with postman. Got the same repsonse (undefined)ā€ƒ

 

Screenshot 2022-02-24 at 20.01.51.png

ā€ƒ

I also tried calling out the param explicitly in the URL with https://DNAC/intent/api/v1/wireless/profile?profileName=null or with 

https://DNAC/intent/api/v1/wireless/profile?profileName The first one give "Profile not Found" and the second one "undefined" as response back.

korey_oehlers
Level 1
Level 1

Cedric,

 

I'm using python not postman, but I was able to get it to work with:

https://{server}/dna/intent/api/v1/wireless/profile?
 
Does that work for you?

Hi Korey

Unfortunately I still get "undefined" by calling https://{server}/dna/intent/api/v1/wireless/profile?

 

Would you mind sharing your whole sample script, so I can try figuring it out?

korey_oehlers
Level 1
Level 1

Sure, no problem.  Here's what I tested with:

import requests
import base64

def get_dna_token():

    url = f'https://{server}/dna/system/api/v1/auth/token'
    payload = None
    auth = f'{username}:{password}'.encode()
    auth = base64.b64encode(auth).decode()
    headers = {
        "Content-Type": "application/json",
        "Authorization": f"Basic {auth}",
        "Accept": "application/json"
    }

    response = requests.post(url, headers=headers, data=payload, verify=False)
    token = response.json()['Token']

    return token

def get_wireless_profile(token):

    url = f'https://{server}/dna/intent/api/v1/wireless/profile?'
    payload = None
    headers = {
        "Content-Type": "application/json",
        "X-Auth-Token": f"{token}",
        "Accept": "application/json"
    }
    
    response = requests.get(url, headers=headers, data=payload, verify=False)

    print(response)

    response = response.json()

    return response

def main():

    token = get_dna_token()

    test = get_wireless_profile(token)

    print(test)

if __name__ == '__main__':

    server = '1.1.1.1'
    username = 'test'
    password = 'test'

    requests.packages.urllib3.disable_warnings()
    main()

Cedric Metzger
Level 1
Level 1

After a lot of trial and error, I figured out, that for some reason my lab-DNAC doesn't like the /dna/intent/api/v1/wireless/profile call. If I do it on customers DNAC or on a dCloud DNAC the call works perfectly fine.

Thanks to everybody who tried helping me.

Have you upgraded your DNAC recently?

You need to restart the API bundle.
CSCvr70208

Jep, but that didn't help. I'll update my DNAC to 2.2.3 to see if anything improves. Otherwise I'll have to open a TAC case I guess.