検索

ディスカッション (0)1
続けるにはログインするか新規登録を行ってください
記事
· 2 hr 前 8m read

Debugging REST APIs using %CSP.Request and %CSP.Response

 

There are numerous excellent tools available for testing your REST APIs, especially when they are live. Postman, various web browser extensions, and even custom ObjectScript written with %Net.HttpRequest objects can get the job done. However, it is often difficult to test just the REST API without inadvertently involving the authentication scheme, the web application configuration, or even network connectivity. Those are a lot of hoops to jump through just to test the code within your dispatch class. The good news is that if we take our time to understand the inner workings of the %CSP.REST class, we will find an alternative option suited for testing only the contents of the dispatch class. We can set up the request and response objects to invoke the methods directly.

Understanding %request and %response

If you have ever worked with REST APIs in InterSystems, you have probably encountered the two objects that drive the entire process: %request and %response. To grasp their utility, we must recall our ObjectScript fundamentals regarding "percent variables." Typically, a variable in ObjectScript can only be accessed directly within the process that defines it. However, a variable prefixed with a percent sign is public within that process. It means that all methods within the same process can access it. That is why by defining those variables ourselves, we can trigger our REST API methods exactly as they would run when receiving a genuine incoming request in the API.

Consider the following basic %CSP.REST class. It features two routes and two corresponding methods. The first route accepts a request containing a date of birth in ODBC format and returns the age in days. The second one accepts a name as a URL parameter, makes sure the request method is correct, and simply echoes a hello message.

Class User.REST Extends %CSP.REST

{

XData UrlMap [ XMLNamespace = "http://www.intersystems.com/urlmap" ]

{

<Routes>

<Route Url="/calc/age" Method="POST" Call="CalcAge" />

<Route Url=”/echoname/:david” Method=”GET” Call=”EchoName” />

</Routes>

}

ClassMethod CalcAge() As %Status

{

    try{

        set reqObj = {}.%FromJSON(%request.Content)

        set dob = reqObj.%Get("dob")

        set today = $P($H,",",1)

        set dobh = $ZDH(dob,3)

        set agedays = today - dobh

        set respObj = {}.%New()

        do respObj.%Set("age_in_days",agedays)

        set %response.ContentType = “application/json”

        write respObj.%ToJSON()

        return $$$OK

    }

    catch ex{

        return ex.AsStatus()

    }

}

ClassMethod EchoName(name As %String) As %Status

{

    

    try{

        if %request.Method '= "GET"{

            $$$ThrowStatus($$$ERROR($$$GeneralError,"Wrong method."))

        }

        write "Hello, "_name

    }

    catch ex{

        write "I'm sorry, "_name_". I'm afraid I can't do that."

    }

}

}

If we attempt to call these methods from a terminal session, they will fail because %request is undefined.

USER>w $SYSTEM.Status.GetErrorText(##class(User.REST).CalcAge())

ERROR #5002: ObjectScript error: <INVALID OREF>CalcAge+2^User.REST.1

Normally, the %CSP.REST class creates this object from the received HTTP request as an instance of %CSP.Request. Likewise, the %response object is developed as an instance of %CSP.Response. Instead of sending an HTTP request, we will define these objects ourselves.

USER>set %request = ##class(%CSP.Request).%New()

USER>set %request.Content = ##class(%CSP.CharacterStream).%New()

USER>do %request.Content.Write("{""dob"":""1900-01-01""}")

USER>set %response = ##class(%CSP.Response).%New()

USER>do ##class(User.REST).CalcAge()

{"age_in_days":45990}

In these few lines, we design the request and initialize its Content property to a %CSP.CharacterStream. This step is vital as otherwise that property will remain undefined and unable to be written to. Another valid alternative would be %CSP.BinaryStream. We populate the content stream with some JSON and initialize the %response to be a %CSP.Response without needing to do anything to it. It simply needs to be defined for the method to run. This time, when we call our class method, we can see the expected output. We could also issue a zwrite %response command to inspect the response content type or HTTP status code for assistance with troubleshooting any issues that might arise.

Testing the output of our class method takes only five lines. Tt is obviously an intentionally simplified example. However, it is far more efficient than navigating the System Management Portal to configure an application and creating the necessary HTTP requests to authenticate and call this method! It also allows us to verify the method in total isolation. When we send a request through the typical tools we employ to test REST APIs, we verify the entire stack: network connectivity, application configuration, authentication mechanism, request dispatching, and the method - all at once. The approach described above, on the other hand, allows us to test exclusively the method defined in the API, making it easier to find the problem during debugging.

Similarly, we can test the second method by setting the appropriate %request object and then calling it. In this case, we will pass the name the same way we would for any other class method.

USER>set %request = ##class(%CSP.Request).%New()

USER>set %request.Method = “GET”

USER>set %response = ##class(%CSP.Response).%New()

USER>do ##class(User.REST).EchoName(“Dave”)

Hello, Dave

Dispatching Requests

We can take this a step further and test the dispatching as well. You may have noticed that I manually checked the CSP request’s HTTP method in the EchoName example. I did it because direct method calls bypass the routing rules, which typically prevents incorrect mapping. 

If we decide to continue with our terminal session with the %request we have defined, we can determine its HTTP method as follows:

USER>set %request.Method = “GET”

To test the dispatch, we should simply call the class DispatchRequest method, and if it is successful, we will see the output from our method again:

USER>do ##class(User.REST).DispatchRequest(“/calc/age/Dave”,%request.Method)

Hello, Dave

With the %request object properly configured, including the HTTP method, we can validate our routes. We can perform a similar test for the age calculation endpoint by setting up our %request again as we did before and employing the POST method

USER>set %request = ##class(%CSP.Request).%New()

USER>set %request.Content = ##class(%CSP.CharacterStream).%New()

USER>do %request.Content.Write("{""dob"":""1900-01-01""}")

USER>set %request.Method = “POST”

USER>set %response = ##class(%CSP.Response).%New()

USER>do ##class(User.REST).CalcAge()

USER>do ##class(User.REST).DispatchRequest(“/calc/age”,%request.Method)

{"age_in_days":45990}

Note that we have defined the URL argument for the DispatchRequest method to be only the part of the URL located in the route node defined in the dispatch class’s XData. his is all we need to test the dispatching! This allows us to test things independently without needing to know the final deployment URL or its web application's configuration. Thus, we have been able to test everything that we typically define within a %CSP.REST class without having to worry about the usual external concerns surrounding it.

By the way, I have been starting the sessions by setting %request to a new instance of %CSP.Request. However, if you plan to do multiple tests in a row, you could also utilize the %request.Reset() method to start over with your request object. The same is true for the %response object.

Since your request might be more complicated than this one, you should familiarize yourself with the properties and methods of the %CSP.Request class. For instance, it is quite common for your API to check the content type of the request and ensure that it is whatever the API expects. In this case, you can set %request.ContentType to be application/json or whatever else is appropriate for your usage. You can configure cookies, mime data, and request data. You can also set the Secure property to simulate whether the request used HTTPS or not. 

A Couple of Caveats

There are two primary considerations to keep in mind when testing this way. First, if our API returns a file, the terminal output can become a bit unwieldy. In such instances, you should redirect the output to a file. We can accomplish that with the following commands:

USER>set %request = ##class(%CSP.Request).%New()

USER>set %request.Method = "GET"

USER>set io = "C:\Users\DavidHockenbroch\Desktop\output.txt"

USER>open io:"NW":10

USER>write $TEST

1

USER>use io do ##class(User.REST).DispatchRequest("/echoname/Dave",%request.Method)

USER>close io

I now have a text file on my desktop that says “Hello, Dave.” Using N and W in the open command will create the file if it does not exist yet, and open it for writing. Note that we check $TEST. If that variable is 0 when we check it, there has been a problem opening the file as a device for writing. This could indicate a file permission issue, or the file may already be opened and locked by another process. As a matter of good practice, we should always remember to close the device.

The second catch is that if we plan on setting a special session event class in the web application configuration, and those custom events will impact the way our REST methods work, it can cause problems since we are bypassing those methods. We will have to call them as class methods manually in the terminal.

Onward!

Now that we have established some means for testing our API without any extra baggage, we are ready to move to our true goal: unit testing. Stay tuned for the next article!

ディスカッション (0)1
続けるにはログインするか新規登録を行ってください
質問
· 3 hr 前

Verbose Troubleshooting %Net.SSH.Session

I was trying to see if we could connect to another Server, we use to execute external scripts using %Net.SSH.Session.

TESTCLIN>set sshSession = ##class(%Net.SSH.Session).%New()

TESTCLIN>set user = <omitted>

TESTCLIN>set host = <omitted>

TESTCLIN>set privateKey = "/nfs/data/ssh/<omitted>"
TESTCLIN>set publicKey = "/nfs/data/ssh/<omitted>.pub"
TESTCLIN>Set statusConnection = sshSession.Connect(host)

TESTCLIN>set statusAuth = sshSession.AuthenticateWithKeyPair(user,publicKey, privateKey,)

TESTCLIN>zwrite statusAuth
statusAuth="0 "_$lb($lb(7510,-19,"SSH Error [80101013]: Callback returned error [80101013] at Session.cpp:494,0",,,,,,,$lb(,"TESTCLIN",$lb("e^ssherror+4^%Net.SSH.Session.1^1","e^AuthenticateWithKeyPair+2^%Net.SSH.Session.1^1","e^^^0"))))/* ERROR #7510: SSH Error '-19': SSH Error [80101013]: Callback returned error [80101013] at Session.cpp:494,0 */

How can I see what the SSH error was in the callback?

ディスカッション (0)1
続けるにはログインするか新規登録を行ってください
お知らせ
· 4 hr 前

[Video] Developing on FHIR in 2025

Hey Community,

Enjoy the new video on InterSystems Developers YouTube:

⏯ Developing on FHIR in 2025 @ Ready 2025

Discover how InterSystems FHIR Server empowers developers, healthcare organizations, and data scientists.It will cover new features and demos such as developing clinical apps with SMART on FHIR, enabling Bulk FHIR exchange for cohort and population health insights, and building analytics close to the data. Learn how our new cloud offers accelerate healthcare innovation and gain some sneak-previews into the major focus areas for 2026.

​​​🗣 Presenter: @Elijah Cotterrell, Product Manager of Health Informatics Platforms at InterSystems

Curious about best practices? Watch this and subscribe for more!

ディスカッション (0)1
続けるにはログインするか新規登録を行ってください
質問
· 5 hr 前

THC Gummies: Your Guide to Hectares Delta-9 Wellness

 

A Modern Guide to Wellness: Why Buying Cannabis Gummies Online is the New Standard

In the rapidly evolving landscape of health and natural wellness, the way we approach relaxation and self-care has fundamentally changed. The days of uncertainty, limited local options, and confusing product labels are thankfully fading. Today, discerning adults across the USA are increasingly turning to convenient, plant-based solutions that offer clarity, consistency, and genuine efficacy. One of the most significant, consumer-driven trends powering this shift is the ability to securely buy cannabis gummies online. This digital accessibility is a game-changer. It empowers you to research, compare, and purchase premium, high-quality hemp products from the absolute comfort and privacy of your home, ensuring you find exactly what fits your unique lifestyle without the sales pressure of a physical retail environment.

For so many people, the journey into hemp-derived wellness begins with a simple, yet profound, desire for balance. We all know the drill: life is often chaotic, filled with back-to-back work deadlines, relentless family obligations, and the constant, nagging buzz of digital technology. Finding a moment to genuinely unplug, reset, and quiet the racing thoughts has become essential for mental survival. This need for reliable calm is precisely where Hectares steps in. We haven't just created a gummy category; we’ve designed a thoughtfully curated collection specifically for the modern adult—someone who values transparency, demands quality ingredients, and needs a product that feels like a natural, seamless extension of their daily routine rather than an awkward interruption.

Decoding the Hectares Gummies Category: Simplicity Meets Science

At Hectares, our core belief is that wellness should never be complicated. Our entire gummies category is built upon the philosophy that you shouldn’t need a degree in biochemistry or be a cannabis expert just to enjoy the balancing benefits of the hemp plant. Our primary focus is on meticulously creating products that are approachable, demonstrably effective, and fully compliant with all stringent federal regulations. When you browse our online collection, you aren't just looking at random edibles; you are examining a carefully formulated range of hemp-derived products that are designed to provide a consistent, predictable experience every single time you use them.

The heart of our collection, the product that sets the standard, revolves around Hectares Delta-9 Gummies. These are anything but your run-of-the-mill convenience store snacks. They are premium wellness tools, precision-crafted with the user’s experience in mind. We specifically utilize hemp-derived Delta-9 THC, which is fully legal on a federal level across the United States, provided it strictly meets the dry weight limit of 0.3%. This compliance distinction is absolutely crucial. It guarantees that you receive the authentic, highly effective calming experience of Delta-9 THC, combined with the assurance of complete legal compliance and adherence to rigorous safety standards.

For those newcomers exploring the space, the technical terminology can sometimes feel overwhelming. You might encounter terms like "hemp derived" and legitimately wonder how it differs from traditional cannabis products. Essentially, hemp derived Delta-9 edibles offer the exact same active compound—Delta-9 THC—that people have historically used for deep relaxation for decades. However, this specific THC is sourced from legally defined hemp plants. This specific sourcing allows us to provide a high-quality product that is legally accessible to people across the country, shipped privately and directly to their doorsteps. It's the modern way to bring the powerful, balancing effects of the plant to you, legally, safely, and conveniently.

The Phenomenal Rise of THC Gummies in Daily Life

Why have THC gummies so quickly become the preferred format for so many people seeking natural wellness? The answer lies in their sheer familiarity, predictable dosing, and unmatched ease of use. Consider the alternatives: oils can be messy and notoriously difficult to dose accurately under the tongue, and smokable products simply aren't for everyone. Gummies, by contrast, are brilliantly straightforward. You know precisely how much active ingredient you are taking. There is absolutely no special equipment required, no preparation needed, and certainly no lingering, strong smell. It is as easy and simple as enjoying a great-tasting, fruit-flavored treat that guides you effortlessly into a state of deep calm after a demanding day.

This format is particularly appealing to those who are fundamentally health-conscious. Many people are proactively moving away from inhalation methods like smoking or vaping in favor of ingesting edibles because gummies are universally perceived as a cleaner, lung-friendly consumption option. Moreover, the effects delivered by edibles tend to be significantly longer-lasting. When you consume a gummy, the active cannabinoid passes through your digestive system and is processed by the liver, resulting in a slower, gradual onset of effects and a sustained experience that can last for several hours. This extended duration makes them exceptionally well-suited for things like uninterrupted evening relaxation, maintaining a focused calm through a challenging task, or ensuring those long weekends are truly dedicated to disconnecting and recharging.

Embracing the Plant-Based Imperative: Vegan THC Gummies

One of the defining pillars of the Hectares brand is absolute inclusivity, especially concerning dietary and ethical choices. We are deeply aware that a massive portion of our customers follow a plant-based or health-conscious lifestyle, which is precisely why we have made a dedicated, firm commitment to offering vegan THC gummies. Traditional gummies, which fill the shelves of most stores, often rely on gelatin, a protein derived from animal connective tissue, thereby automatically excluding a large segment of health-conscious and ethically minded consumers. We fundamentally believe that no one should ever have to compromise their ethical values or dietary restrictions to enjoy the fantastic benefits of the hemp plant.

Our sophisticated formulations purposefully utilize pectin, a completely fruit-based alternative to gelatin, which allows us to achieve that perfect, soft, satisfying texture without any animal-based ingredients whatsoever. This commitment to purely vegan THC gummies is much more than just a trend; it's a foundational part of a broader, more responsible trend in natural wellness. Consumers today demand cleaner labels. They want to know with certainty that what they are putting into their bodies is free from unnecessary artificial additives and fully aligns with a compassionate, sustainable lifestyle. By choosing our vegan options, you are not only making a choice for your own health; you are actively supporting a more sustainable, ethical, and forward-thinking approach to modern product manufacturing.

Spotlight Product: Hectare’s 30mg Vegan Delta 9 Gummies

Within our rich and diverse category of THC gummies, there are specific products designed to meet every tolerance level and preference. While we offer excellent standard strengths perfect for beginners, today we want to specifically highlight a potent and highly effective option tailored for those who are more experienced or require a significantly stronger effect: Hectare’s 30mg Vegan Delta 9 Gummies.

This particular product is a powerhouse that truly stands out for its exceptional potency and unparalleled purity. Each precisely measured gummy delivers a robust 30mg of hemp-derived Delta-9 THC. This represents a significant increase in potency from our more standard 10mg options, making it the perfect choice for seasoned users who have established their body’s response and are specifically looking for a deeper, more profound level of relaxation or therapeutic effect.

Because of this carefully calibrated higher potency, these vegan delta-9 gummies offer not only powerful efficacy but also excellent overall value. Crucially, they are crafted with the exact same high standards as all our products—they are 100% vegan, naturally gluten-free, and bursting with great natural fruit flavors. Whether you are actively looking to melt away significant, high-level stress or simply prefer a higher concentration due to a naturally higher tolerance, this product consistently delivers a reliable, powerful, and deeply satisfying experience every time.

The Irrefutable Benefits of Shopping Online for Wellness

The focus keyword of this article, cannabis gummies online, is central to the modern user experience, and for good reason. The online shopping model offers distinct, significant advantages over the traditional experience of visiting a physical dispensary or local shop.

  1. Privacy and Absolute Discretion: For a variety of personal reasons, not everyone feels entirely comfortable walking into a physical store to buy hemp products. Shopping online with Hectares allows you to browse and select products in total privacy. Furthermore, all products are shipped securely and discretely in unmarked packaging. Your personal wellness journey is entirely personal, and we respect and prioritize that need for discretion from start to finish.
  2. Unmatched Information and Transparency: When you are standing in a store, you might feel rushed or feel pressured to rely solely on the advice of a sales clerk. Online, you have all the time in the world. You can leisurely read detailed product descriptions, meticulously check third-party lab reports (COAs), and fully understand exactly what is in the hemp derived Delta-9 edibles you are considering before committing to a purchase. Hectares provides full transparency and accessible data so you can personally verify the potency and absolute purity of every single batch.
  3. Ultimate Convenience and Efficiency: The modern world is undeniably busy and demanding. Being able to order your favorite wellness products while sitting comfortably on your couch, waiting in a line, or taking a quick break at work saves invaluable time and mental energy. With reliable, fast shipping, restocking your supply of Hectares Delta-9 Gummies is truly effortless.

This combination of transparency, information access, and convenience is why buying cannabis gummies online is the smart, modern choice.

Integrating Gummies into a Holistic Wellness Routine

Hectares gummies are most effective when they are consciously used as a deliberate, integrated part of a broader, holistic approach to well-being. They should not be viewed as a standalone "magic fix," but rather as a highly effective tool to help you achieve the overall balance and calmness you seek.

Many of our loyal customers strategically use them to establish a profoundly calming nighttime ritual. Taking a gummy approximately an hour before you plan to sleep can serve as a gentle, yet firm, signal to your body and mind that it is time to deliberately wind down. This helps to quiet the racing, anxious thoughts that often accompany a very busy modern life, facilitating a smooth transition into restful sleep.

Others find them remarkably useful for creative endeavors or for enhancing social gatherings. A low, carefully measured dose of THC gummies can help subtly loosen mental inhibitions and make social interactions feel more fluid, relaxed, and less anxious. The key, always, is to find the dosage that works uniquely for you. Because everyone's endocannabinoid system is distinct, the ultimate experience can and will vary from person to person. This is why we consistently and firmly advocate for the "start low and go slow" principle, especially when trying a new potency like our specialized 30mg options.

Safety and Responsibility: A Non-Negotiable Priority

While THC gummies are a fantastic, natural addition to a holistic wellness routine, responsible and mindful use is absolutely paramount to ensuring a positive experience every time. FDA guidelines and general safety standards emphatically suggest that you should never, under any circumstances, operate heavy machinery or drive a vehicle after consuming any THC products. The effects of THC can and will impair your reaction times, coordination, and depth perception.

In addition to personal safety, always keep these products stored securely out of the reach of children and pets. Their appealing, fruit-like appearance, great taste, and smell can be highly attractive to little ones and animals. Therefore, storing them in a secure, high place or a dedicated, locked container is an essential and non-negotiable part of responsible ownership and product usage.

Frequently Asked Questions

Q: Is it legal to buy cannabis gummies online in the USA? A: Yes, it is fully legal to buy cannabis gummies online as long as they are classified as hemp derived Delta-9 edibles containing less than 0.3% Delta-9 THC on a dry weight basis, which is in accordance with the federal 2018 Farm Bill. Hectares rigorously ensures that all our products strictly meet these federal requirements.

Q: Are Hectares products truly suitable for vegans? A: Absolutely. We specifically specialize in vegan THC gummies. We utilize fruit pectin instead of animal-based gelatin, ensuring that our products are 100% free from animal derivatives, making them fully suitable for those following strict vegan, vegetarian, or simply clean-label diets.

Q: How do Hectares Delta-9 Gummies compare to edibles from a marijuana dispensary? A: Hectares Delta-9 Gummies offer a highly similar experience to many dispensary edibles because the active molecule, Delta-9 THC, is chemically identical regardless of whether it comes from hemp or marijuana. The main, crucial difference is the sourcing and the federal legal status that allows us to ship our products nationwide, legally and directly to your door.

Q: What is the absolute best way for a beginner to start with your 30mg vegan delta-9 gummies? A: If you are completely new to this higher potency, we strongly and highly recommend cutting the vegan delta-9 gummies into halves or even quarters. 30mg is considered a very strong dose. Always start with a very small amount (e.g., 5-10mg), wait at least a full two hours to feel the complete effects, and then only adjust your dose the following day as necessary.

Q: Why should I specifically choose hemp derived Delta-9 edibles over other cannabinoids like Delta-8? A: Many users overwhelmingly prefer hemp derived Delta-9 edibles because Delta-9 is the classic, primary cannabinoid associated with the full and beneficial "entourage effect" of deep relaxation and natural mood elevation. It is widely cited by users as providing a more complete, familiar, and satisfying experience compared to other alternative variants like Delta-8 or Delta-10.

Conclusion

Navigating the world of natural wellness and relaxation should be empowering, not complicated. By making the deliberate choice to buy cannabis gummies online from a reputable, transparent brand like Hectares, you are choosing guaranteed quality, verifiable safety, and unmatched convenience. Our unwavering commitment to crafting premium Hectares Delta-9 Gummies ensures that you receive a highly consistent, enjoyable, and effective experience every single time. Whether you opt for our standard, balanced doses or the more potent vegan delta-9 gummies, you are actively supporting a plant-based, transparent, and ethical approach to health. We warmly invite you to explore our full category, find the precise flavor and strength that truly resonates with your needs, and step into a more balanced, deeply relaxed version of your life. Wellness is an ongoing journey, and Hectares is here to be your consistent, reliable partner every step of the way.

ディスカッション (0)1
続けるにはログインするか新規登録を行ってください