API

Check access requests

There might be a lot of API operations available for an object/resource, but not all of them is applicable for every object. It is not possible to register a sales order that does not have any items, or a sales order that is already registered. Some API operations are not available because of the modules/submodules activated by the customer, while other API operations are restricted to a permission which a duty/role does not have.

Check access requests makes it possible to find out which API operations that are not available for the current user, and also why it is not available.

In the RamBase client we are using check access requests to hide context menu items which are not available. In the menu item called "Unavailable menu items" you can find API operations that cannot be requested, including an explanation of why.

The request URI is always the same:

POST https://api.rambase.net/check-access

Example of request body:

In this example we are checking the API operations "Register sales order" (100055), "Cancel sales order" (100041) and "Copy sales order to new sales quote" (100437) for sales order 100087:

1
{
2
               'checkAccess':
3
               [
4
                  {
5
                     'objectType': 'APIOperation',
6
                     'objectId': 100055,
7
                     'data': 'sales/orders/100087'
8
                  },
9
                   {
10
                     'objectType': 'APIOperation',
11
                     'objectId': 100041,
12
                     'data': 'sales/orders/100087'
13
                  },
14
                  {
15
                     'objectType': 'APIOperation',
16
                     'objectId': 100437,
17
                     'data': 'COA/100087'
18
                  }
19
               ]
20
}

You might have noticed that the data element is provided with two different syntaxes. One is the resource uri of the object where the operation can be found (sales/orders/100087), the other is the object in the RamBase key format (COA/100087). Both are referring to the same object and is equally valid.

As you can see in the example response below, nothing is returned for "Copy sales order to new sales quote" (100437). This indicates that you can request that specific operation for sales order 100087. The other two API operations is not allowed, and the explanation can be found in the translated error message.

1
{
2
          'checkAccessResults': [
3
            {
4
              'translatedErrorMessage': 'The sales order is already registered',
5
              'object': {
6
                'objectId': 100055,
7
                'objectType': 'ApiOperation',
8
                'objectLink': 'https://api.rambase.net/system/api/api-operations/100055'
9
              },
10
              'missingPermission': {
11
                'permissionId': null,
12
                'name': null,
13
                'permissionLink': null
14
              }
15
            },
16
            {
17
              'translatedErrorMessage': 'Only active (status higher than 1 and lower than 9) sales orders can be cancelled',
18
              'object': {
19
                'objectId': 100041,
20
                'objectType': 'ApiOperation',
21
                'objectLink': 'https://api.rambase.net/system/api/api-operations/100041'
22
              },
23
              'missingPermission': {
24
                'permissionId': null,
25
                'name': null,
26
                'permissionLink': null
27
              }
28
            }
29
          ]
30
}