Regarding doing search operation using post

48 views
Skip to first unread message

Samundiswaran P Velpandian

unread,
Jan 4, 2022, 4:56:17 PM1/4/22
to hapi...@googlegroups.com
Hi Team,

I am searching a resource with post method(Since I have SSN as one of the parameter), I cannot expose all the parameters in URL param(This is the reason, I am avoiding GET). When I do it, RestfulServer is not binding the parameter that I post in the body of the message. But the one that I pass in Query Parameter is getting bind properly.

Any resolution/suggestion for this?

Regards,
Sam

James Agnew

unread,
Jan 4, 2022, 5:22:40 PM1/4/22
to Samundiswaran P Velpandian, HAPI FHIR
Are you using the correct POST syntax? You need to add "/_query" to the URL, and use a content type of "application/x-www-form-urlencoded"

--
You received this message because you are subscribed to the Google Groups "HAPI FHIR" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hapi-fhir+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/hapi-fhir/CAOvQqUZ4PJLYZ7ktTEPVi11c%2BRdMjDrAnTiSiSR%2B2sM82_y2BQ%40mail.gmail.com.

James Agnew

unread,
Jan 5, 2022, 8:07:36 AM1/5/22
to Samundiswaran P Velpandian, HAPI FHIR
If it's working in Postman but not with the library, that suggests that the library is probably not sending what you think it is.

Try using Postman to intercept and capture the request to see what it looks like: https://learning.postman.com/docs/sending-requests/capturing-request-data/capturing-http-requests/

Cheers,
James

On Tue, Jan 4, 2022 at 6:04 PM Samundiswaran P Velpandian <sam.esw...@gmail.com> wrote:
I searched with above settings in post man, it worked fine. However, When I do React axios post with content type set to  "application/x-www-form-urlencoded", Doesnt bind the variable. Am I missing something?

Sample code, I tried:
await axios.post<fhir.Bundle>('http://localhost:8080/pa/fhir/Patient/_search?'+partialMatchRequest,{identifier},{headers:{'content-type':'application/x-www-form-urlencoded'}})
partialMatchRequest->has request params that is getting bound properly. (family=Joseph&gender=&deceased=false&given=&given=&birthdate=)
Regards,
Sam

On Tue, Jan 4, 2022 at 5:28 PM Samundiswaran P Velpandian <sam.esw...@gmail.com> wrote:
I tired adding /_query to the URL instead of /_search, Request didn't reach the @Search method itself. However, I changed the content type to  "application/x-www-form-urlencoded" this helped me receiving the parameters that I added in body. Thanks James, for your input.

Regards,
Sam
Reply all
Reply to author
Forward
0 new messages