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”
}
]
}
wyclif
(Wyclif Luyima)
February 22, 2018, 7:12pm
2
rajuraghuwanshi:
`{
“person”: “UUID”,
“identifiers”: [
{
“identifier”: “6”,
“identifierType”: “value”,
“location”: “value”,
“preferred”: “true”
},
{
“identifier”: “51”,
“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.
wyclif
(Wyclif Luyima)
February 23, 2018, 8:15am
5
Why did it suddenly start working? What was the issue?
I just clean the tomcat directory and restart it.
dkayiwa
(Daniel Kayiwa)
February 25, 2018, 8:36pm
8
Can you paste the error log details at pastebin.com ? Then here, you just share the paste url
please find the pastebin link :
https://pastebin.com/q8SGJvH9
dkayiwa
(Daniel Kayiwa)
February 26, 2018, 6:56am
10
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"}
dkayiwa
(Daniel Kayiwa)
February 26, 2018, 7:07am
12
Looks like you are trying to make a post before authenticating.
This page shows how to authenticate https://wiki.openmrs.org/display/docs/REST+Web+Services+API+For+Clients
No, I have set the authentication in the http request where username is admin and pass is Admin123.
private static OkHttpClient createAuthenticatedClient(final String username, final String password) {
// build client with authentication information.
OkHttpClient httpClient = new OkHttpClient.Builder().authenticator(new Authenticator() {
@Override
public Request authenticate(Route route, Response response) throws IOException {
String credential = Credentials.basic(username, password);
return response.request().newBuilder().header("Authorization", credential).build();
}
}).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.
wyclif
(Wyclif Luyima)
February 26, 2018, 5:33pm
16
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.
dkayiwa
(Daniel Kayiwa)
February 28, 2018, 6:48pm
18
Hi,
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