Eduard Lebedyuk · Jul 17, 2019 go to post

Use ccontrol qlist to get structured information about available instances.

ccontrol qlist [<instance>] [nodisplay > outputfile]
Display a quick list of information about all installed instances, in a format suitable for parsing in command scripts.
The record for an instance contains fields separated by "^" (carats):

  • Field 1: instance name
  • Field 2: instance directory
  • Field 3: version identifier
  • Field 4: current status for the instance
  • Field 5: configuration file name last used
  • Field 6: SuperServer port number
  • Field 7: WebServer port number
  • Field 8: JDBC Gateway port number
  • Field 9: Instance status (e.g., ok, warn, alert)
  • Field 10: Product name of the instance
  • Field 11: Mirror Member Type (e.g., Failover, Disaster Recovery)
  • Field 12: Mirror Status (e.g., Primary, Backup, Connected)
Eduard Lebedyuk · Jul 17, 2019 go to post

How is it valid JSON?

1. JSON accepts only double quotes. Single quotes are not valid.

2. Property names must be quoted (in double quotes). error/txt are not quoted.

Here's JSON standard.

Eduard Lebedyuk · Jul 17, 2019 go to post

Should be

  If glo["ABC",type="K" Set restmode=0           /*except if a kill on ^ABC*/ 

Instead of

  If glo["^ABC",type="K" Set restmode=0           /*except if a kill on ^ABC*/ 
Eduard Lebedyuk · Jul 17, 2019 go to post

Globals can't have duplicate keys.

After I execute your code and call

zw ^Data 

I get this output:

^Data("Athens")=7
^Data("Boston")=3
^Data("Cambridge")=1
^Data("London")=4
^Data("New York")=2
Eduard Lebedyuk · Jul 17, 2019 go to post

Please post CROSRestAPI as text.

Can you get InterSystems IRIS or a complete version of Cache/Ensemble?

Service Unavailable error is because of license limitations on TRYCACHE.

Eduard Lebedyuk · Jul 16, 2019 go to post

Create a response wrapper and use it. %ListOfObjects is serial, not persistent.

Class MyResponse Extends %Persistent {

Property Snapshots As List Of EnsLib.SQL.Snapshot;

}
Eduard Lebedyuk · Jul 16, 2019 go to post

Well, maybe it's a handwritten response?

I'd recommend contacting the API developer and verifying that API responses would be indeed JSON.

Eduard Lebedyuk · Jul 16, 2019 go to post

Can you make the same call to the API using Postman and show the response?

It's very strange that API returns non-json response.

Does my code snippet throw the same error?

Eduard Lebedyuk · Jul 16, 2019 go to post

You can simplify your code to this:

set dynObj = {}.%FromJSON(objHttpResponse.Data)
set iter = dynObj.%GetIterator()
while iter.%GetNext(.key , .value )  {
       write "key = "_key_" , value = "_value,!

}

Also json is a string so in your code sample it won't have %FromJSON method.

Eduard Lebedyuk · Jul 16, 2019 go to post

Well, the JSON you posted is not a valid JSON. Where did you get it?

Valid JSON looks like this:

{
   "error":[
      {
         "txt1":"error msg1"
      },
      {
         "txt2":"error msg2"
      }
   ]
}
Eduard Lebedyuk · Jul 16, 2019 go to post

1.Variables are defined or referenced via <var>, yes, but you can pass the values to the Installer from your script. For example, check MDX2JSON installer:

Set pVars("User")="web"
Set pVars("Password")="dsweb"
Set pVars("Namespace")="TEMP3"
Set pVars("Import")=1
Set pVars("SourceDir")="C:\temp\MDX2JSON\MDX2JSON"
Do ##class(MDX2JSON.Installer).setup(.pVars)

2. You set environment variable in cmd (Windows):

set NEWVAR=SOMETHING

And after that you can get it from installer with:

$system.Util.GetEnviron("NEWVAR")
Eduard Lebedyuk · Jul 15, 2019 go to post

They go through your web server (i.e. Apache, NodeJS, IIS) directly.

You can serve files via REST, from files or XDatas. Here's an example in WebTerminal app, but it can be generalized to server arbitrary files from FS.

Eduard Lebedyuk · Jul 11, 2019 go to post

i was able to convert the HttpResponse.Data to String and than to the Dynamic Object

You don't need to convert to string, pass stream to FromJSON method and it would work.

send a JSON data to a REST API.

Set tAge = 23
Set pRequest= {"name":"abcdefghi","salary":123,"age":(tAge) }
Eduard Lebedyuk · Jul 11, 2019 go to post

What version are you on? If 2016.2+ then you can convert JSON stream to dynamic object via:

set dynObj = {}.%FromJSON(req.HttpResponse.Data)
Eduard Lebedyuk · Jun 29, 2019 go to post

It sets object id directly instead of setting oref.

Consider these 2 classes:

Class Person Extents %Persistent {

Property EmployedAt As Company;

}


Class Company Extends %Persistent {

}

Usually you assign Company to Person this way:

set person = ##class(Person).%New()
set companyId = 123
set company = ##class(Company).%OpenId(companyId)
set person.EmployedAt = company

But with PropertySetObjectId you can expedite things

set person = ##class(Person).%New()
set companyId = 123
do person.EmployedAtSetObjectId(companyId)

The main advantage is that company object doesn't have to be opened.

Eduard Lebedyuk · Jun 29, 2019 go to post

That's explicit if you code it.

By default PropertyGet()  method exists, but hidden - it's an implicit getter.

Getters defined via SQLComputeCode work for both SQL and objects iirc.

Eduard Lebedyuk · Jun 29, 2019 go to post

Is it Xades?

I've done Xades signing, but not with RSA algorithms. Still, might be useful for you. Drop me your GitHub username if you need the code.

To add Xades support I used a reference implementation in .Net - read the Xades docs on how it's supposed to work, then decompiled .Net libraries to see how it all actually works, and recreated it in ObjectScript.

Eduard Lebedyuk · Jun 27, 2019 go to post

This is possible:

Class MyClass As %Persistent {

Method SaveToNs(Namespace = {$namespace}) As %Status
{
  new $namespace = ""
  set $namespace = Namespace
  quit:'##class(%Dictionary.CompiledClass).%ExistsId(..%ClassName(1)) $$$ERROR($$$GeneralError, "Class is undefined in: " _ Namespace)
  set sc = ..%Save()
  quit sc

}

}