What is the base URL for openmrs REST web services?

i want to acces rest services without using a any web app… what is the base URL am i supposed to use , ?

i thought it wud be something like this

http://localhost:8082/openmrs-standalone/module/webservices/GET/openmrs-standalone/ws/rest/v1/person

@tendomart @k.joseph @dkayiwa @wyclif

Have you taken time to look at https://wiki.openmrs.org/display/docs/Sample+REST+calls and https://wiki.openmrs.org/display/docs/REST+Web+Services+API+For+Clients

1 Like

thx bro @tendomart , let me look at them

Hi @mozzy,

Actually, You don’t need to use a web app to get the information through the web services. Web Services will serve the information when we make a request to the respected endpoint.

You can simply use your browser to check the responses from the REST Web Services or you can use the swagger documentation to try the REST Web Services. But I strongly advised to use the Postman application for the testing purposes (some rest endpoints may request user authentication, you can give it in the Postman also).

Some of the sample web services endpoints in the openMRS are,

If you have any questions regarding Web Services, Feel free to ask it here :slight_smile:

1 Like

thx @suthagar23 that was exactly the question i had. i thought some how openmrs webservices are only restricted to be accesed thru webb aps

helo @suthagar23… my standalone was installed with a demo database,

all the first two urls return valuea, but i wud expect this url to return all the patients present in my database

http://localhost:8082/openmrs-standalone/ws/rest/v1/patient

but instead it returns this error here

https://hastebin.com/evowataxas.vbs

wat could be the problem

and then alsoaccording to the documentation , i wud expext the data in a jason format , but i get it in anxml format

all the first two urls return valuea, but i wud expect this url to return all the patients present in my database

Actually, we couldn’t get all the patient list through the single REST API (Assume there is about 100K patients in the system, then how can you manage those using a single API Response :smile:). So you should specify the patient identifier like q=10001v in the request query

.and then alsoaccording to the documentation , i wud expext the data in a jason format , but i get it in anxml format

Unfortunately, This API doesn’t support the output in a JSON format, but you can convert this XML response to JSON format in the Postman.

1 Like

thx bro @suthagar23

now here is may jquery code. i want to return a list of all modules and assigh ti to data table … but wen i run the module, it tells me AJAX ERROR,

<script type="text/javascript">
$(document).ready(function() {
	
	  /* var patients = [
		
		           [ '1' , '2'],
		           [ '1' , '2'],
		           [ '1' , '2']
		        
	               ]; */
	
	   var $table= $('#pat2');
	   
	   // EXECUTE THAT COE ONLY WHERE WE HAVE THE TABLE
	   if ( $table.length) {
		   
		   var Jasonurl = 'http://localhost:8082/openmrs-standalone/ws/rest/v1/module';
		   
			
		   
		   
		   $table.DataTable ( {
			   
			    lengthMenu: [[ 5, 10, -1],["five ","ten" ,"ALL"]],
			    pageLength : 5,
				//data:patients for arrays
				ajax : {
					
					url : Jasonurl
					//dataScr : ''
					
				},
				
				columns : [
					
					/* { data :  "patientId" },
					
					{ data :  "personName" },
					
					{ data :  "patientIdentifier" } */
					
                    { data :  "uuid" },
					
					{ data :  "display" },
					
					{ data :  "description" }
					
					
					
				]
				   
			});
		   
		   
	   } 
	    
	
	
	
});
</script>

Could you please post the error logs here?

HTTP400: BAD REQUEST - The request could not be processed by the server due to invalid syntax.
(XHR)GET - http://localhost:8082/openmrs-standalone/ws/rest/v1/module?_=1526638477251

but the same request can be processed in a browser and returns all the list of modules present

(XHR)GET - http://localhost:8082/openmrs-standalone/ws/rest/v1/module?_=1526638477251

There is a value(_=152663847725) added to this URL. Can you please check the AJAX Request URL?

1 Like

the url is plain , it doesnt contain it

http://localhost:8082/openmrs-standalone/ws/rest/v1/module

Hello there, is there any way to get base url dynamically because i want call an api in module script. I am using hardcoded url for now. but its not good way to deal with I need the dynamic baseurl for that. Thanks