Create Client
#
Create clientTo create a new client record you will need to make a TLS request to the OpenHIM API for the below method and endpoint and supply the JSON object for the client record.
#
ExampleNote: In the examples below, we are using the token authentication type to authenticate requests
- Languages
- Sample Data
Before we can send our request to the OpenHIM API we need to ensure that we construct our valid HTTP headers to successfully authenticate with the OpenHIM API.
- NodeJS
- Bash
Copy the below code at the bottom of your nodejs script that handles the authentication of the OpenHIM headers as described in the authentication section.
Replace the openhimOptions
values with the correct implementation details and supply the SampleData
payload to submit. You will also need to update the clientPassword
variable to your desired password as well as to ensure you set the passwordSalt
/ passwordHash
values in your SampleData
payload
Execute the below command in your terminal to run the nodejs script
Ensure that you have created your bash script to construct the HTTP authentication headers and send the request to the OpenHIM API as described in the authentication section.
Execute the below command in your terminal where the file is located with the required arguments. Replace the placeholder arguments with the correct implementation details and ensure your SampleData.json
file exists with the client object.
#
generate a valid password hash and saltand execute the above bash script with the below command
Once you have generated the hash and salt for the password, supply it into the SampleData.json
payload to be submitted
Execute the below command in your terminal to create the client
The response status code will be 201
if successful.
Client Roles: if the supplied values in the array do not yet exist, it will be created and added to the client, but if the supplied role already exist, it will just be assigned to the client.
Client password details: To generate the the client password details (Salt/hash) you can follow the same steps as described within the authentication section