Manage Users
Although the administrator users of the B2B site technically can manage user data directly in the WordPress admin area, the only approved way to manage users is from the Navision ERP via API. This ensures that the user data is always in sync with the data in the ERP system.
This API connects the Navision ERP and the B2B website. This means that any user related action is initiated from within the Navision ERP that communicates with the B2B portal via API.
API
The B2B site utilizes the WordPress REST API.
Accessing the API is only possible if the request is authenticated with a username and application password. The username and it’s application password can be passed along to REST API requests served over https:// using Basic Auth / RFC 7617.
Request / Response Format
The payload format is plain JSON and the standard HTTP verbs used for the requests.
Successful requests will return a 200 OK HTTP status.
Errors
Occasionally errors might occur when accessing the API. There are four possible types:
| Error Code | Error Type |
|---|---|
| 400 Bad Request | Invalid request, e.g. using an unsupported HTTP method. |
| 401 Unauthorized | Authentication or permission error. |
| 404 Not Found | Requests to resources that don’t exist or are missing. |
| 500 Internal Server Error | Server error |
API error example:
{ "code": "rest_forbidden", "message": "Sorry, you are not allowed to do that.", "data": { "status": 401 }}Available actions
The users API allows to create, update, and delete individual users.
Currently, the following actions are possible via the API:
Create User
Creation of a single user.
HTTP request
[POST] /wp-json/tcsgeu/v1/customersJSON payload
| Key | Value | Description |
|---|---|---|
| ContactNo | string | User’s unique identifier in the Navision ERP. It is also used as a unique identifier of the user in the WordPress user database. Serves as the username for login to the users account. |
| Name | string | User’s name |
| string | User’s email address. Can be used interchangeably with the ContactNo as the username for login to the users account. | |
| PhoneNo | string | User’s phone number. |
| CustomerNo | string | The company identifier - used for querying the price and stock information from the Navision API. |
| CompanyName | string | The company name. |
Example payload
{ "ContactNo":"CT000022", "Name":"Mr. John Doe", "PhoneNo":"+3611234567", "CustomerNo":"01234567", "CompanyName":"Company Name Ltd."}Example response for successful user creation:
{ "user_id": 18, "user_login": "CT000022"}Modify User
Modify a single user.
HTTP request
[POST] /wp-json/tcsgeu/v1/customers/<ContactNo>JSON payload
Currently, the following user data can be modified via the API:
| Key | Value | Description |
|---|---|---|
| Name | string | User’s name |
| string | User’s email address. | |
| PhoneNo | string | User’s phone number |
Example payload
{ "Name":"Mr. John Doe", "PhoneNo":"+3611234567",}Example response
{ "user_id": 18, "user_login": "CT000022"}Disable User
Disabling a single user.
While disabled the user can’t log in. Nothing is deleted from the account.
HTTP request
[POST] /wp-json/tcsgeu/v1/customers/disableJSON payload
| Key | Value | Description |
|---|---|---|
| ContactNo | string | User’s unique identifier in the Navision ERP. |
Example request
{ "ContactNo":"CT000022",}Example response
{ "user_id": 18, "user_login": "CT000022"}Enable User
Enable a single user.
HTTP request
[POST] /wp-json/tcsgeu/v1/customers/enableJSON payload
| Key | Value | Description |
|---|---|---|
| ContactNo | string | Users unique identifier in the Navision ERP. |
Example request
{ "ContactNo":"CT000022",}Example response
{ "user_id": 18, "user_login": "CT000022"}Delete User
Delete a single user.
HTTP request
[DELETE] /wp-json/tcsgeu/v1/customers/<ContactNo>JSON payload
Currently, this action requires no payload.
Example response
{ "user_id": 18, "user_login": "CT000022"}