Trying to create a basic REST API call

I am trying to access openEMR from API call.
First, by using postman. I found a good demo server that I can access from the browser:

When using postman, I am providing this in the request body:
“grant_type”: “password”,
“username”: “admin”,
“password”: “pass”,
“scope”: “default”

But still I get 401 Unauthorized as response.

The goal is to create a .NET application that can access openEMR, this is my simple code:

            string URL = "";
            string URL2 = "";

            var client = new FhirClient(URL);

            Patient myPat = new Patient();
            myPat.Identifier.Add(new Identifier("", "4568532"));
            myPat.Active = true;

            HumanName patName = new HumanName();
            patName.GivenElement.Add(new FhirString("Vincent"));
            patName.Use = HumanName.NameUse.Official;

            myPat.Gender = AdministrativeGender.Male;
            myPat.BirthDate = "1989-01-21";

            myPat.ManagingOrganization = new ResourceReference() { Reference = "Organization/NHSDEVORG" };


I get an exception:
“Operation was unsuccessful because of a client error (Unauthorized). Body has no content.”

How do I provide a body in the request?

Thanks for any help!

hi @perreq, see the api readme

based on your code you should try a post request on patient fhir endpoint

Fhir authorization endpoint

Hi @perreq,

I had faced same issue way back please find below solution for same

Thanks for all response guys!

I guess the “curl -X POST” is PHP. I still dont know how to implement this in a c#.NET application.

I found a huge project on Github in c#. But I just want to start with a simple “hello world” example. Maybe that is not possible to do if I only have the FhirClient object to play around with.

Has anyone of you created a .NET application?

Hi @Nilesh_Hake,

I tried your suggestion but I do not know how to enable the apache mod_rewrite. If you could elaborate on this, it would be a great help.


send error here.

Hi @Nilesh_Hake,

I get 401 unauthorized error with an empty body when I call this below API on postman.

using version 5.0.2

I am trying to creating RESTAPI using openemr and postman, i dont know the steps please anybody help me , i followed this link but i am not getting openemr/ at master · openemr/openemr · GitHub