How to POST multiple observations through REST

When I am sending a single observation then it is getting created but for multiple observations it is throwing an error 500.

For single observations my query is - TYPE- POST URI - /openmrs-standalone/ws/rest/v1/obs BODY- {
“concept” : “5086AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA”, “person” : “610b0696-7529-4b4a-b65b-37336a75962a”, “obsDatetime”: “2017-07-24T15:33:49+05:30”, “encounter”: “3bc0672d-ebc6-4e65-aae1-8a1d4de759bf”, “value” : “90” }

For multiple I am sending TYPE- POST URI - /openmrs-standalone/ws/rest/v1/obs BODY- [{“concept” : "5089AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA ", “person” : “610b0696-7529-4b4a-b65b-37336a75962a”, “obsDatetime”: “2017-07-24T15:33:49+05:30”, “encounter”: “3bc0672d-ebc6-4e65-aae1-8a1d4de759bf”, “value” : “99” }, { “concept” : “5090AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA”, “person” : “610b0696-7529-4b4a-b65b-37336a75962a”, “obsDatetime”: “2017-07-24T15:33:49+05:30”, “encounter”: “3bc0672d-ebc6-4e65-aae1-8a1d4de759bf”, “value” : “185” }] The error is here https://pastebin.com/uBaJmZa9

Have you considered the encounter resource having multiple observations?

The obs resource does not support posting multiple obs.

As Daniel says, the encounter resource would let you create multiple obs (in an encounter).

@darius and @dkayiwa Is there a way of creating sessions in openMRS. I mean to say that I am sending too many REST request with username and password. Is it possible that some of my REST POST queries are not working because there’s already the user logged in. If I could somehow create a session through REST and then send all the request and finally close the session.

See the Authentication section here: https://wiki.openmrs.org/x/P4IaAQ (Note that this is the first google hit for “openmrs rest session”)

Perhaps the way you’re making REST calls using Mirth does not maintain a session?

Thanks @darius I found out that for sending REST request one “needs” to send a request header of Authorization:Basic = username:password or one has to set a cookie of sessionId. Eg- URL: http://localhost:8083/openmrs-standalone/ws/rest/v1/visit METHOD: POST

[HEADERS] Set-Cookie: jsessionid=C17C12C50D5C194E2487982F08C4BAEB Authorization:Basic: YWRtaW46QWRtaW4xMjM=

[PARAMETERS]

[CONTENT] { “patient”:“c342807d-fc65-4de1-983e-424c4add487d”, “visitType”:“7b0f5697-27e3-40c4-8bae-f4049abfb4ed”, “location”:“bf38803c-b24c-4d54-bd8d-15fe17a79d0d” }