API - Get List of Portal Users

Parent Previous


API - Get List of Portal Users


QUANTIL allows you to obtain the list of portal user accounts by making requests programmatically rather than logging in as usual and looking at the Administer Contacts page.


Using this functionality requires you to make calls to our server using valid portal credentials.


The following examples use the popular open source utility curl to obtain a list of portal users.


Step 1:  Obtain a session cookie to allow future API calls.  

This example assumes a portal user login "joeuser" with password  "mypassword".  (You should substitute a valid set of credentials.)

It writes cookies to a file named cookiefile.


curl -i -s 'https://portal.quantil.com/login.htm' -c cookiefile -d 'userName=joeuser&password=mypassword'

HTTP/2 302

x-frame-options: SAMEORIGIN

set-cookie: JSESSIONID=CB6F82BA7A61BA555688C388347A5A55; Path=/; Secure; HttpOnly

location: /index.htm;jsessionid=CB6F82BA7A61BA555688C388347A5A55

content-type: text/html;charset=UTF-8

content-language: en

date: Fri, 08 Jun 2018 20:37:35 GMT


In this case, the HTTP response code 302 indicates success, and cookiefile contains the session information to be used in step 2.

If your credentials are invalid, you will get an HTTP response code 401 along with the same HTML that you would see in the portal if you incorrectly enter your password.


Step 2: Request the list of users


This example makes use of the previously obtained session to obtain the list of portal users.  The response is in JSON format and includes the portal user's login name, name, email address, type of account, and when the user last logged in.  The HTTP response code 200 indicates a successful request.


curl  -i -s --url 'https://portal.quantil.com/api/contacts' -b cookiefile

HTTP/2 200

cache-control: private

expires: Thu, 01 Jan 1970 00:00:00 UTC

x-frame-options: SAMEORIGIN

content-type: application/json;charset=UTF-8

date: Fri, 08 Jun 2018 20:54:09 GMT


{"contactList":[{"id":21760,"loginName":"johnsmith","lastName":"Smith","firstName":"John","status":"Normal","email":"jsmith@somedomain.com","contactType":"Administrator","dateLastLogin":"2018-06-06 07:00:54 UTC"},{"id":21761,"loginName":"juanita","lastName":"Gomez","firstName":"Juanita","status":"Normal","email":"jgomez@somedomain.com","contactType":"Viewer","dateLastLogin":null},{"id":21762,"loginName":"kthompson","lastName":"Thompson","firstName":"Karen","status":"Normal","email":"kthompson@somedomain.com","contactType":"Administrator","dateLastLogin":"2018-06-06 06:30:01 UTC"}]}


You can make this call multiple times if you wish. If you get no results, it may be because the cookie has expired, so you need to repeat Step 1.  You can also confirm this by checking the HTTP response headers from your call.   For example, a redirection to the https://portal.quantil.com/login.htm page with a response code of 302  indicates the session has expired:


curl  -i -s --url 'https://portal.quantil.com/api/contacts' -b cookiefile

HTTP/2 302

cache-control: private

expires: Thu, 01 Jan 1970 00:00:00 UTC

set-cookie: JSESSIONID=870F1AA36E44EA6EE359CAA6B6645DF1; Path=/; Secure; HttpOnly

location: https://portal.quantil.com/login.htm

content-type: text/html;charset=UTF-8

date: Wed, 06 Jun 2018 19:18:16 GMT




Step 3: Log out

The session cookie obtained in step 1 will automatically expire after some time, but you can explicitly disable it as well for security by making a call to https://portal.quantil.com/logout.htm as in the following example.


curl -i -s --url 'https://portal.quantil.com/logout.htm' -b cookiefile

HTTP/2 302

cache-control: private

expires: Thu, 01 Jan 1970 00:00:00 UTC

x-frame-options: SAMEORIGIN

location: login.htm

content-type: text/html;charset=UTF-8

content-language: en

date: Fri, 08 Jun 2018 21:01:06 GMT