govind
(Govind Sharma)
January 29, 2019, 7:08am
1
Attribute error occurring with custom API.
{
"identifiers": [
{
"identifier": "1234-6",
"identifierType": "8d79403a-c2cc-11de-8d13-0010c6dffd0f",
"location": "8d6c993e-c2cc-11de-8d13-0010c6dffd0f",
"preferred": true
}
],
"person": {
"gender": "M",
"age": 48,
"birthdate": "1970-01-01T00:00:00.000+0100",
"birthdateEstimated": false,
"dead": false,
"deathDate": null,
"causeOfDeath": null,
"names": [
{
"givenName": "Thoma1s6",
"familyName": "Smi1th6"
}
]
}
}
Response received. https://pastebin.com/wLjAzuZH
please reply fast.
dkayiwa
(Daniel Kayiwa)
January 29, 2019, 9:10am
2
From your log, this means Caused by: org.openmrs.api.APIAuthenticationException: Privileges required: Get Identifier Types that you may not be logged in.
govind
(Govind Sharma)
January 29, 2019, 10:27am
3
i have given id- admin; password; Admin@123 in authentication in header.
try {
DefaultHttpClient httpclient = new DefaultHttpClient();
httpclient.getCredentialsProvider().setCredentials(new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT),
new UsernamePasswordCredentials("admin", "Admin123"));
HttpPost httppost = new HttpPost("http://192.168.0.111:8080/openmrs/ws/rest/v1/patient");
System.out.println("executing request " + httppost.getRequestLine());
httppost.addHeader("Accept", "application/json");
httppost.addHeader("content-type", "application/json");
try {
//Set the request post body
StringEntity userEntity = new StringEntity(params1);
httppost.setEntity(userEntity);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
HttpResponse response;
response = httpclient.execute(httppost);
HttpEntity entity = response.getEntity();
System.out.println("----------------------------------------\n" + response.toString());
System.out.println(response.getStatusLine());
BufferedReader br = new BufferedReader(new InputStreamReader((response.getEntity().getContent())));
System.out.println("Output from Server .... \n");
while ((output = br.readLine()) != null) {
System.out.println(output);
}
if (entity != null) {
System.out.println("Response content length: " + entity.getContentLength());
}
if (entity != null) {
entity.consumeContent();
}
httpclient.getConnectionManager().shutdown();
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
please reply fast.
dkayiwa
(Daniel Kayiwa)
January 29, 2019, 11:25am
4