Thanks for sharing this.  I would be interested in seeing some of the data structures you decided on with dummy data.

I would typically use a percent (%) global if I wanted a global to be accessible across multiple namespaces but I don't usually mix percent globals and class storage definitions.

You could also try a tool like Postman to test service calls and authentication methods.  If you tick the Password checkbox it enables Basic authentication (plain text username/password) is enabled. You can  also use bearer tokens instead, which is a popular authentication scheme.

While authentication/authorization isn't really covered in great detail, REST and Relaxation is a good starting point for REST development and it comes with a video and source code.

You should also double-check your URL is correct and resource permissions are correct. You probably only need permissions on the ENSEMBLE namespace and there might be a resource that defines this. Your URL is probably something like http://yourserver/rest/coffeemakerapp/coffeemaker

I was hoping to convert the above sample into an Internal REST API so that Bearer Authentication could replace Basic Authentication

Great article!

Can you enable HTTP Bearer token authentication on Web Applications via the System Management Portal?

All I see under 'Allowed Authentication Methods' are options for:

  • Unauthenticated
  • Password 
  • Login Cookie

Perhaps I am missing a trick somewhere?

What does your Edit Web Application settings look like? What allowed authentication methods are enabled?

Pretty embarassing result for me. I misinterpretted how ObjectScript treats equals(=) operator when used with a write and thus lost a lot of marks.  Its never something I've come across but now I am well and truely informed. Good article. From a support perspective, I often have to evaluate expressions in the terminal to check my understanding is correct. It can be mighty fustrating if you spend all day assuming an expression is interpretted one way, only to find your assumption to be incorrect! Agree with Avoid ambiguous or easily misinterrepted code. Also use brackets, they are your friends.

. They are two different platforms and is most likely why you could not find ConfigureServices in the Intersystems docs.  For a Micosoft SQL Server, your ConfigureServices method could have

            services.AddDbContext<MyMSDBContext>(cfg =>
            {

                cfg.UseSqlServer(_config.GetConnectionString("MyConnectionString"));
            });

but I haven't seen any examples in Caché! Perhaps there is a development opportuntiy to write a NuGet package? Here's a Microsoft link to other popular database providers supported within .NET Core.

PS. If you use RESTful HTTP methods to talk to the database then you don't need a database provider as the data can be returned as part of the HTTP Response.