Here are some initial suggestions / comments (no particular priority):

  1. Standardize on capitalization in naming. For example classnames EX.example and Sample.Classes, and property names name and Location.
  2. Use singular for your classname, e.g. Class rather than Classes
  3. Use meaningful classnames, e.g. Sample.Employee rather than Sample.Classes
  4. Use meaningful method names. e.g. insert or Insert rather than hello
  5. Avoid namespace switching unless really necessary. Presumably in your case the Sample.Classes class is in the USER namespace and the EX.example is somewhere else (maybe you wrote it in your SAMPLES namespace).
  6. For a REST interface, consider returning results in a structured form, e.g. JSON.
  7. Make good use of indenting. Perhaps you already have done this and the post to DC has mangled it.
  8. Avoid using Z-commands, $Z-functions and $Z if non-Z equivalents are available. For example, SET $NAMESPACE="USER" instead of ZN "USER". Note that you can also preserve the current $NAMESPACE value using NEW $NAMESPACE which will automatically reinstate the value when the stack level is exited.

I hope this is a useful start.

Did you answer your own question here? If so, DC now allows you to add an Answer to your own, and even mark it as the accepted answer. But I have a followup question: did you determine whether your solution is "legal" (i.e. a quirk of Management Portal), or is it a bug and likely to get "fixed" in a future release (thus breaking your app)?