Encounter Provider Creation Issue

Hello, I am trying to post encounter provider but getting an error 400 Bad request. The REST API documentation says that i can create provider using ‘/encounter’ endpoint. I am posting it like this

Json POST

I am querying the provider using GET call at session and passing it to the scope. The post request fails, I get a error 400 Bad request. The moment i make POST without encounter provider array, it gets POSTED. Can someone point out where I am going wrong? Thanks

@hardikk08 do you mind posting the whole error log at pastebin.com ?

Ok I have console logged the .then(response). Here is the link,

Pastebin Error Log

@darius or @mksd It would be very helpful if you could look into this!

Which openmrs platform version are you running?

Platform version 2.0.5 and Ref app - 2.6

Could the outdated version be the issue causing this problem by any chance?

And which version of the rest webservices module?

Do you get the same error when you post on this server? qa-refapp.openmrs.org

Rest Web services Module - 2.19.0.f2b4a2

I dont really know how do i try to post this on the qa server, because i don’t have encounter or patient uuid right?

Also one more question, can i post any kind of string into any key, as in while posting an encounter if i post {location: “Openmrs”} Will this work, there is no back end logic for accepting values right, or i can post any string to attributes?

From your error log “ConversionException: encounterproviders on class org.openmrs.Encounter” it looks like you are using “encounterproviders” instead of “encounterProviders”

No I am using encounteProviders only, check the payload Here

Also I have posted the screenshots of the payload.

Then it could be that the log you sent is not exactly what happened when at the time of the post. Look for a patient on qa-refapp.openmrs.org and try reproduce it there.

No what i posted, the log is the console.log(response) I get from server after the encounter payload doesn’t gets posted. This is very weird. Will try to reproduce on the qa-refapp.

Hey i tried to reproduce it there here is the response-

curl -X POST “https://qa-refapp.openmrs.org/openmrs/ws/rest/v1/encounter/21d662dd-61c2-4fe1-b5d5-56bb9ad40dd7/encounterprovider” -H “accept: application/json” -H “authorization: Basic YWRtaW46QWRtaW4xMjM=” -H “content-type: application/json” -d “{ “encounter”: “21d662dd-61c2-4fe1-b5d5-56bb9ad40dd7”,“uuid”: “82544a07-5299-4e75-8eb5-9c72ae52c47b”}”

I am not an openmrs expert and not sure if i did it the right way, but i am getting 400 bad request. But on doing a get call for encounters i can see that encounter provider is being posted when it is selected in the visit from the dropdown.

Am i calling the correct endpoint? /encounter, if i even tried with /encounter/uuid/encounterprovider" but it still doesnt gets posted.

log.txt (18.4 KB) Can someone have a look at this log? It says column provider_id cannot be null, what could that be? I am posting provider and it even shows up in console that provider is being sent.

How does your post look like?

{ patient: patient, encounterType: window.constantConfigObj.encounterTypeVisitNote, visit: visitId, encounterProviders: [{ provider: $scope.uuid, encounterRole: “73bbb069-9781-4afc-a9d1-54b6b2270e03” }], encounterDatetime: date2 };

What is the actual value contained in $scope.uuid?

user uuid value from GET /session endpoint

It is done, i just realized i was posting user uuid from /session, which is wrong. I corrected it by querying provider with the user uuid from /session and fetching the provider uuid, and then putting that into the JSON post. And it worked, thanks for the help @dkayiwa and @tendomart

@hardikk08 glad you were helped out.