If you’d like to use BioStar 2 New Local API as a RESTful API for your own customization or other purposes, you can simply reference this article. This article will help you to Add or Delete Users from Access Group in your BioStar 2 via using New local API. 


Make sure you take a good look at the example code of the C# program built for API calls. You can simply copy & paste the source code to use the same function in your own integration. 


You can also see how to call the API functions via Postman, which is a program used for RESTful API calls.


For more details of the API, please refer to https://bs2api.biostar2.com/#intro


Create New Access Group


POST Create New AG

https://127.0.0.1/api/access_groups


This request is used to make a new Access Group (AG)

The parameters are as follows:


ParameterTypeRequiredDescription
nameStringYThe name of the AG. Must be unique
descriptionStringNAG's description
usersNumberNList of user(s) id of the AG
user_groupNumberNList of user group(s) id of the AG
access_levelsNumberNList of access level(s) id of the AG
floor_levelsNumberNList of floor level(s) id of the AG

floor_levels parameter is not available yet. Skip the parameter or put it like this > "floor_levels": ""
For numeric value (such as id's), the value can be put on a quote or not

Known errors:

  • Putting "/" at the end of the endpoint
  • name is a required and unique parameter


Request Body

 {
    "AccessGroup": {
        "name": "access_group_test",
        "description": ""
        "users": [
            {
                "user_id": 1750
            }
        ],
        "user_groups": [
            {
                "id": 10871
            }
        ],
        "access_levels": [
            {
                "id": 53
            }
        ],
        "floor_levels": [],
    }
}



Update Access Group


PUT Update an AG

https://127.0.0.1/api/access_groups/:id


This endpoint is used to replace Access Group with id {id}/:id values with the one specified by parameters below:

ParameterTypeRequiredDescription
nameStringYThe name of the AG. Must be unique
descriptionStringNAG's description
new_usersArrayNList of user(s) id to be added to AG
delete_usersArrayNList of user(s) id to be deleted from AG
user_groupNumberNList of user group(s) id of the AG
access_levelsNumberNList of access level(s) id of the AG
floor_levelsNumberNList of floor level(s) id of the AG

Known errors:

  • Repeating the same value on parameter with multiple options



1. Adding User to existing Access Group

 {
    "AccessGroup": {
        "user_groups": [
            {
                "id": 10871,
                "name": "User Group 1"
            }
        ],
        "new_users": [
            {
                "user_id": 1753
            },
            {
                "user_id": 1749
            }
        ]
    }
}


2. Deleting User to existing Access Group

 {
    "AccessGroup": {
        "user_groups": [
            {
                "id": 10871,
                "name": "User Group 1"
            }
        ],
        "delete_users": [
            {
                "user_id": 1753
            },
            {
                "user_id": 1750
            }
        ]
    }
}

3. Adding and Deleting User at the same time

 {
    "AccessGroup": {
        "user_groups": [
            {
                "id": 10871,
                "name": "User Group 1"
            }
        ],
        "new_users": [
            {
                "user_id": 1750
            },
            {
                "user_id": 1753
            }
        ],
        "delete_users": [
            {
                "user_id": 1749
            }
        ]
    }
}


4. Adding/Deleting User Group to Access Group

In this example, "User Group 1" with ID 10871 is already assigned to the Access Group.
  • When you add/delete user group, it will remove any previous data and add the one that you input
    Ex: If you have an existing User Group 1, and on update you  put only User Group 2 on user_group parameter, then User Group 1 will be deleted from Access Group and only User Group 2 remains.
  • If you want to add more user group, then you will need to specify the current user groups. If you only put the addition all the previous data will be removed.
  • To skip a record from updating, either skip the paramete. In below example, users are not updated.


Example 1: Adding User Group 2 from exisitng Access Group.

 {
    "AccessGroup": {
        "user_groups": [
            {
                "id": 10871,
                "name": "User Group 1"
            },
            {
                "id": 10872,
                "name": "User Group 2"
            }
        ]
    }
}

Example 2: Deleting User Group 2 from exisitng Access Group. 

{
    "AccessGroup": {
        "user_groups": [
            {
                "id": 10871,
                "name": "User Group 1"
            }
        ]
    }
}

Example 3: Deleting User Group 1 and adding User Group 2. 

{
    "AccessGroup": {
        "user_groups": [
            {
                "id": 10872,
                "name": "User Group 2"
            }
        ]
    }
}