Admin API - some things to check if you are having issues

The administrative API (aka ‘Admin API’) is a programmatic API to manipulate objects within the the visualization server (such as user objects, datasets, roles, etc). You can read more about the setup here.

Usually an API key is used to authenticate the requests. Below are a few things you want to check if you are having issues.

CONFIRM SETTINGS

Make sure you have these settings applied to the visualization server configuration

ADMIN_API_DEMO_LIST = [’’]
ADMIN_API_URL_LIST = [’
’]
DATA_API_ENABLED = True

RBAC PERMISSION

Make sure API keys correspond to a user that has proper RBAC permissions. All operations coming through the Admin API are checked against the same RBAC rules as when performing them through the UI console.

CURL COMMAND

Below is an example curl command that I just ran on a test system using a normal user account but with “admin like” RBAC privileges. Notice how the user account is created without issue.

Try running this simple test command on your system with proper api key just to see if it creates dummy user account.

>$ curl -s
> -X POST
> -H “Content-Type: application/x-www-form-urlencoded”
> -H “Authorization: apikey cfWUOh1aAxXW8GIot7cbAovU5NHabGWu4tz0nVFEDzo5KFap”
> -d ‘data=[{“username”:“new_user_test_shaun099”, “password”: “dummyuser”, “is_superuser”: false, “date_joined”: “2017-05-02 12:00:00 UTC”, “last_login”: “2017-05-02 12:00:00 UTC”, “groups”: [], “roles”:[]}]’
> 10.0.0.221:38888/arc/adminapi/v1/users

[{“id”: 72, “username”: “new_user_test_shaun099”, “is_superuser”: false, “is_active”: true, “date_joined”: “2018-12-08 02:34:42 UTC”, “last_login”: “N/A”, “first_name”: “”, “last_name”: “”, “groups”: [], “roles”: [], “profile”: {}}]

API DEMO BROWSER PAGE

Also, the API Demo is another page you can try. You have to navigate to this page: http://xxxx:38888/arc/apps/apidemo
You can read more about it here: http://documentation.arcadiadata.com/4.4.0.0/#pages/topics/admin-api-demo-examples.html

Make sure to login as the account being used in the API calls. And see if you can fetch user objects, clone, and create.

Hello,
I’m trying to create an user from rest client like postman , also from my java code but every time I’m getting error code 500 - Invalid data format error.

Request URL - https://:38888/arc/adminapi/v1/users
POST method
Below are the headers we are using to make the call, but every time I’m getting an error “Invalid Data format”
Header
‘Authorization’: ‘apikey krGyk1sYpSAkuaxzc0oUbcFd’

Body
[{“username”:“testuser”,
“password”:“temp123”
}]

What is it we are doing incorrect here? Could you please share some sample to create a user. We eventually want to make a create user call from java code.
We are able to make successful GET calls though.

Please help.

@mamtajoshi Can you try running the CURL command? would be great to start off with that and make sure that works for you.

Assuming that works, then it must be something with your tool setup. My initial guess you need extra quotes

But let’s first confirm the very basic is working for you - ie, CURL. Thanks

I just ran this and it worked fine:

  $ curl -s -X POST -H "Content-Type: application/x-www-form-urlencoded" 
    -H "Authorization: apikey Q5j3ospm0TAPGE4TZUrwj8KTcGHUpJzqfbT0wM7a2u8qLKS0" 
    -d 'data=[{"username":"new_user_test_shaun9999", "password": "new_user_test_shaun9999"}]' 
    10.0.0.221:38888/arc/adminapi/v1/users**

$ [{“id”: 83, “username”: “new_user_test_shaun9999”, “is_superuser”: false, “is_active”: true, “date_joined”: “2019-02-26T00:22:42+00:00”, “last_login”: “N/A”, “first_name”: “”, “last_name”: “”, “groups”: [], “roles”: [], “profile”: {}}]

I even ran this using SOAP UI and it worked.

You might want to refer to this post on more info on general SOAP UI setup:

1 Like

Thanks a lot Shaun. The calls are working now. I think I wasn’t passing the values headers etc. correctly.

URL url = new URL(“https://host:38888/arc/adminapi/v1/users”);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setDoOutput(true);
conn.setRequestMethod(“POST”);
conn.setRequestProperty(“Authorization”, adminAuthToken);
conn.setRequestProperty(“version”, “1”);
conn.setRequestProperty(“Content-Type”,“application/x-www-form-urlencoded”);

String input = “data=[{“username”:“mamtatest”,“password”:“dummypassword”,“first_name”:“mamta”,“last_name”:“joshi”,“roles”: [{“id”: 4,“name”: “Consumer”}]}]”;

OutputStream os = conn.getOutputStream();
os.write(input.getBytes());
os.flush();

System.out.println(conn.getResponseCode() );

1 Like