cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Highlighted
New Contributor

Using vWLAN APIs

Jump to solution

Hello, I'm testing API. I read a manual. And i have some problems:


When i enter query:

curl -H “Accept:application/xml” -X GET -k -u root@adtran.com:blueblue https://server_ip:3000/internalusers?active_domain_name=default

reply

curl: (52) Empty reply from server

If i change parameters, server reply html, but i need xml. What i do wrong?

vWLAN version: 2.6.0.24


Thanks,

Evgeniy.


Tags (1)
0 Kudos
Reply
1 Solution

Accepted Solutions
Highlighted
Anonymous
Not applicable

Re: Using vWLAN APIs

Jump to solution

If you haven't already, take a look at Configuration Guide - Using APIs with vWLAN. This should give you plenty of examples. That said, you should probably modify your curl command.

curl -i -H "Accept:application/xml" -H "Content-Type:application/xml" -X GET -k -u ${user}:${pass} https://server_ip:3000/locations?active_domain_name="$domain"

I use this in scripts, and I just tested again before posting.

View solution in original post

14 Replies
Highlighted
Anonymous
Not applicable

Re: Using vWLAN APIs

Jump to solution

If you haven't already, take a look at Configuration Guide - Using APIs with vWLAN. This should give you plenty of examples. That said, you should probably modify your curl command.

curl -i -H "Accept:application/xml" -H "Content-Type:application/xml" -X GET -k -u ${user}:${pass} https://server_ip:3000/locations?active_domain_name="$domain"

I use this in scripts, and I just tested again before posting.

View solution in original post

Highlighted
New Contributor

Re: Using vWLAN APIs

Jump to solution

Thank you very much! I's working!

In manual not written by symbol " in active_domain_name.

The final request:

curl -H "Accept:application/xml" -H "Content-Type:application/xml" -X GET -k -u root@adtran.com:blueblue https://server_ip:3000/internalusers?active_domain_name="default"

Thanks,

Evgeniy.

0 Kudos
Reply
Highlighted
New Contributor

Re: Using vWLAN APIs

Jump to solution

Hello, I have anothe question.

I want to delete internal user, but i don't know parameters in xml request. Maybe someone had to deal with it.



0 Kudos
Reply
Highlighted
New Contributor

Re: Using vWLAN APIs

Jump to solution

If i used -X DELETE . I have reply HTML page 404.

0 Kudos
Reply
Highlighted
New Contributor

Re: Using vWLAN APIs

Jump to solution

Can you help in get API for username from clients with the ip address ?

curl -H "Accept:application/xml" -H "Content-Type:application/xml" -X GET -k -u root@adtran.com:blueblue https://server_ip:3000/active_user_statuses?active_domain_name="default"

0 Kudos
Reply
Highlighted
Anonymous
Not applicable

Re: Using vWLAN APIs

Jump to solution

I apologize in advance if I misunderstood your question, but you cannot pull specific fields directly from the UI. You would have to pull the whole list of active users and parse that out.

Maybe we can still help though. I tend towards Python, and I request JSON from the API. The reason being that JSON format translates directly to Python lists and dictionaries. First off, use these HTML headers.


HEADERS = {


        'Accept': 'application/json',


        'Content-Type': 'application/json'


    }



The following code snippet is a method from a larger class which has some defined cleanup functions, so it won't translate directly into other code, but you can perhaps see that what I do is pull the active_user_statuses resource and return a list of individual statuses.


def all_user_status(self):


        """Returns a Python list of active user statuses."""


        # Statuses will be returned as a list of dictionaries.


        # Note that the vWLAN API cannot always process this request as there


        # is a lot of information that gets returned.


        active_user_statuses = []


        for status in self.get('active_user_statuses', self.name):


            if status == 'error':


                msg = 'Error: vWLAN API was unable to process this request'


                active_user_statuses.append(msg)


            else:


                status = self.convert_values(status['active_user_status'])


                active_user_statuses.append(status)


        return active_user_statuses



Now, to answer your question, here's an example of how what I do.


>>> import vwlan


>>> d = vwlan.Domain(server_host, server_admin, admin_password, domain_name)


>>> for status in d.all_user_status():


...     if 'name' in status:


...             print status['name']


...     if 'host_name' in status:


...             print status['host_name']


...     print status['ipaddr']


...


user01


user01Phone5s


10.5.2.170


>>>



tl;dr: You need to parse the output returned from the API call, and look for name, host_name, and ipaddr.

0 Kudos
Reply
Highlighted
New Contributor II

Re: Using vWLAN APIs

Jump to solution

Hello all.

Anyone can help me create location by using API.

I'm try example from documentation, but not work

curl -i -H “Accept:application/xml” -H “Content-Type:application/xml” -X POST -k -u xxx:xxx https://10.1.1.20:3000/locations -d "<locations><location><name>WIFI0</name><vlan type="integer">1000</vlan><cidr>100.64.0.0/21</cidr></location></locations>"

  1.        <script> 
  2.           jQuery(function(){jQuery.gritter.add({image:'/assets/error-c9302e0b7e951136df31bed19b68d929.png',title:'Form Error',text:'Name can\'t be blank'});});  
  3.        </script> 
  4.        <script> 
  5.           jQuery(function(){jQuery.gritter.add({image:'/assets/error-c9302e0b7e951136df31bed19b68d929.png',title:'Form Error',text:'CIDR must be a valid IP address'});});  
  6.        </script> 
  7.        <script> 
  8.           jQuery(function(){jQuery.gritter.add({image:'/assets/error-c9302e0b7e951136df31bed19b68d929.png',title:'Form Error',text:'CIDR netmask should be between 0 and 32.'});});  
  9.        </script> 
  10.        <script> 
  11.           jQuery(function(){jQuery.gritter.add({image:'/assets/error-c9302e0b7e951136df31bed19b68d929.png',title:'Form Error',text:'Vlan is not a number'});});  
  12.        </script> 
0 Kudos
Reply
Highlighted
Anonymous
Not applicable

Re: Using vWLAN APIs

Jump to solution

There are two things you can try.

  1. Make sure you include the active_domain_name parameter.
  2. Remove the encapsulating locations tag.

Since you are posting to the locations page anyways, you don't need those outer tags. Your URL should look something like this.


https://<server>:3000/locations?active_domain_name="default"


You can also use the active_domain_id if you happen to know the ID, but in most cases you would not have that data point.

Your data in XML or JSON will look like this.


<location><name>WIFI0</name><vlan type="integer">1000</vlan><cidr>100.64.0.0/21</cidr></location>


{"location" : {"name": "WIFI0", "vlan": 1000, "cidr": "100.64.0.0/21"}}


One thing you might consider is manually creating a Location, then use the GET method to pull that data from the system. You can then make sure you have all the formatting correct. Also note that when you create an item you use a POST (which you have correctly done) and you will not include an ID. So when you GET the data, you will see an ID. You do not need to set that when you create a new item.

Highlighted
New Contributor II

Re: Using vWLAN APIs

Jump to solution

Thank you. It's work.