# How to POST multiple observations through REST

**URL:** https://talk.openmrs.org/t/how-to-post-multiple-observations-through-rest/12554
**Category:** Development
**Tags:** meetings, module, developers-forum
**Created:** [July 25, 2017, 8:44am UTC](https://talk.openmrs.org/t/how-to-post-multiple-observations-through-rest/12554 "2017-07-25T08:44:20Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![sidsid14](https://talk.openmrs.org/letter_avatar/sidsid14/32/5_5575768a8748004e209b776fc1b2916d.png) [@sidsid14](https://talk.openmrs.org/u/sidsid14)
#### Post date: [July 25, 2017, 8:44am UTC](https://talk.openmrs.org/t/how-to-post-multiple-observations-through-rest/12554/1 "2017-07-25T08:44:20Z")

</div>

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](https://pastebin.com/uBaJmZa9)

---

<div class="post-metadata">

### Author: ![dkayiwa](https://talk.openmrs.org/user_avatar/talk.openmrs.org/dkayiwa/32/179_2.png) [@dkayiwa](https://talk.openmrs.org/u/dkayiwa)
#### Post date: [July 27, 2017, 3:33pm UTC](https://talk.openmrs.org/t/how-to-post-multiple-observations-through-rest/12554/2 "2017-07-27T15:33:02Z")

</div>

Have you considered the encounter resource having multiple observations?

---

<div class="post-metadata">

### Author: ![darius](https://talk.openmrs.org/user_avatar/talk.openmrs.org/darius/32/8082_2.png) [@darius](https://talk.openmrs.org/u/darius)
#### Post date: [July 27, 2017, 5:01pm UTC](https://talk.openmrs.org/t/how-to-post-multiple-observations-through-rest/12554/3 "2017-07-27T17:01:40Z")

</div>

The `obs` resource does not support posting multiple obs.

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

---

<div class="post-metadata">

### Author: ![sidsid14](https://talk.openmrs.org/letter_avatar/sidsid14/32/5_5575768a8748004e209b776fc1b2916d.png) [@sidsid14](https://talk.openmrs.org/u/sidsid14)
#### Post date: [July 27, 2017, 5:17pm UTC](https://talk.openmrs.org/t/how-to-post-multiple-observations-through-rest/12554/4 "2017-07-27T17:17:56Z")

</div>

@darius and @dkayiwaIs 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.

---

<div class="post-metadata">

### Author: ![darius](https://talk.openmrs.org/user_avatar/talk.openmrs.org/darius/32/8082_2.png) [@darius](https://talk.openmrs.org/u/darius)
#### Post date: [July 27, 2017, 5:24pm UTC](https://talk.openmrs.org/t/how-to-post-multiple-observations-through-rest/12554/5 "2017-07-27T17:24:01Z")

</div>

See the Authentication section here: [https://wiki.openmrs.org/x/P4IaAQ](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?

---

<div class="post-metadata">

### Author: ![sidsid14](https://talk.openmrs.org/letter_avatar/sidsid14/32/5_5575768a8748004e209b776fc1b2916d.png) [@sidsid14](https://talk.openmrs.org/u/sidsid14)
#### Post date: [July 28, 2017, 5:22am UTC](https://talk.openmrs.org/t/how-to-post-multiple-observations-through-rest/12554/6 "2017-07-28T05:22:25Z")

</div>

Thanks @dariusI 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](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” }
