openMRS API to create a patient

Hi ! I am new here and i have been trying to make some API calls to test it, using curl. I am following the examples provided here https://wiki.openmrs.org/pages/viewpage.action?pageId=52625683, in particular this one:

echo '{

“preferredIdentifier”:{

"identifier":"abc123ez",

"identifierType":"8d79403a-c2cc-11de-8d13-0010c6dffd0f",

"location":"Unknown Location"},

“preferredName”:{

"givenName":"Magpie",

"familyName":"Programmer"},

“birthdate”:“1978-01-15”,

“gender”:“M”

}’ | curl -i -u admin:Admin123 -H “Content-type: application/json” -X POST -d @- https://demo.openmrs.org/openmrs/ws/rest/v1/patient

However I always get 404 not found. Is this the expected behaviour?

the demo server is down right now. try using https://qa-refapp.openmrs.org/openmrs/ws/rest/v1/patient

Check out the swagger

https://qa-refapp.openmrs.org/openmrs/module/webservices/rest/apiDocs.htm

If you’re trying to learn first play with the get endpoint try to retrieve a patient and see the attributes then work on the post-call :slightly_smiling_face:

Thank you both for the prompt reply! I will follow your advice, thank you again.

EDIT: I just tried out your page where I was able to generate a very simple command (copy pasted from there): curl -X GET “https://qa-refapp.openmrs.org/openmrs/ws/rest/v1/patient” -H “accept: application/json”

However when I run it in my terminal I get a 500 - Internal error. Is it working for you?

Hopefully you find the documentation at rest.openmrs.org helpful and, if not, you can help us improve it. :slight_smile:

@rainbow & @ayesh, @magp is your customer. If they didn’t find your API docs easily/first, why not? If the documentation isn’t answering their questions, what’s missing?

1 Like

:smile: exactly. :100:

2 Likes