Error in patient registration

Dear @tendomart How do i create a patient with two identifier using REST api.

`{ “person”: “UUID”, “identifiers”: [ { “identifier”: “6”, “identifierType”: “value”, “location”: “value”, “preferred”: “true” }, { “identifier”: “51”, “identifierType”: “value”, “location”: “value”, “preferred”: “true” } ] }

But if i use only one identifier then it works fine.

{ “person”: “UUID”, “identifiers”: [ { “identifier”: “6”, “identifierType”: “value”, “location”: “value”, “preferred”: “true” } ] }

I see that you are setting both identifiers as preferred, shouldn’t you be setting one as preferred? Can you also share the error you get when you submit multiple identifiers?

1 Like

Dear @wyclif, Yes i tried it with one identifier set true and other one is false but it’s not working. Error that i am getting :400 Bad request

Dear @wyclif,

Now it’s working,Thanks for helping me.

Why did it suddenly start working? What was the issue?

I just clean the tomcat directory and restart it.

Hi @wyclif, @dkayiwa

Getting error while POST of visit

URL: http://localhost:8083/openmrs/ws/rest/v1/visit METHOD: POST

BUT when i tried with open mrs REST client(http://localhost:8080/openmrs/module/webservices/rest/apiDocs.htm) it works.

Can you paste the error log details at Then here, you just share the paste url

please find the pastebin link :

How does your post data look like?

please find the JSON data format

{"startDatetime":"2017-10-30 00:00:00","patient":"e3f1c0dc-c177-48b3-9827-4771348e46f6","location":"bbc1765a-f736-42f8-86d0-1fc0b08c26b5","attributes":[{"attributeType":"38b68a4d-ca2a-4701-b97f-1bbb355d47a5","value":""},{"attributeType":"297292e4-51e5-40fe-aa06-14b23e32560a","value":""},{"attributeType":"8b00ddc0-0a3a-42bc-bcde-4013e0dcba51","value":""},{"attributeType":"b8b3ac39-6ac5-4062-99a1-492f31040092","value":""},{"attributeType":"a127a856-d4a1-45d1-9960-60ca73a2da72","value":""},{"attributeType":"4ecba6c9-3dc3-46b8-891a-02dd34eefe07","value":""},{"attributeType":"2445c5d2-356e-483b-9731-997ab7460885","value":""},{"attributeType":"cf29fe64-72a6-443e-a8b4-2fa3885d8506","value":""}],"visitType":"160f5fbd-701f-4ac5-91f5-9efffa320f1c"}

Looks like you are trying to make a post before authenticating. This page shows how to authenticate

No, I have set the authentication in the http request where username is admin and pass is Admin123.

How have you done it?

private static OkHttpClient createAuthenticatedClient(final String username, final String password) {
	// build client with authentication information.
	OkHttpClient httpClient = new OkHttpClient.Builder().authenticator(new Authenticator() {
		public Request authenticate(Route route, Response response) throws IOException {
			String credential = Credentials.basic(username, password);
			return response.request().newBuilder().header("Authorization", credential).build();

by using this httpClient first i create person and patient object using REST api and then try to create visit object, but it throws Error.

You might want to confirm that the credentials are correct and that the user has the necessary privileges

Hi, Credentials are correct because person and patient object created successfully with same credentials but when it comes to visit throws an Error.

Do you get the same error when you try to post using this page?


problem is solved.Tomcat server runs the old war file where i had not set the authentication header value, so i re-configure the tomcat server and deployed the updated project war file.

Thanks for helping me