Update Mediator
#
Update MediatorTo update a mediator, you will need to make a TLS request to the OpenHIM API for the below method and endpoint and supply the JSON object of the mediator.
Note: For a mediator to be updated the version number in the update object has to be greater than current one for that mediator. If the mediator does not exist a new one is created.
#
ExamplesNote: In the examples below, we are using the token authentication type to authenticate requests
#
Update Example- 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.
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 mediator update object.
The response status code will be 201
whether the update succeeds or not. To check the status of the update, fetch the updated mediator or check the console.
#
Set Mediator configurationTo set a mediator's configuration, you will need to make a TLS request to the OpenHIM API for the below method and endpoint and supply the JSON object of the mediator's configuration.
The response will have an http status code of 201
if successful, 404
if the mediator referenced by urn
cannot be found and 400
if the config supplied cannot be validated against the configuration definition supplied in the mediator registration message.
This endpoint can only be called by an admin user.
#
Setting Mediator's configuration Example- 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.
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 mediator's config object.
The response status code will be 200
if successful.