Eduard Lebedyuk · Jul 18, 2019 go to post

Try

C:\InterSystems\Cache\bin\cache.exe -s C:\InterSystems\Cache\mgr -U %%SYS C:\Users\Zdenda\Desktop\run.script 
Eduard Lebedyuk · Jul 18, 2019 go to post

You need to either escape your command or use a separate file for a script. I recommend a file.

Eduard Lebedyuk · Jul 18, 2019 go to post

I've got minimal security settings

Then you don't need to provide user and password.

  I can use this method right Login(Username As %String, Password As %String)?

No. First line of script - user, second line - password. After that - ObjectScript.

Do $system.OBJ.Load("Installer.xml", "c") I dont know why. 

Try full path. Also this method returns status, check it:

Set sc =  $system.OBJ.Load("/path/to/Installer.xml", "c")
Write:('sc) $System.Status.GetErrorText(sc) 
Eduard Lebedyuk · Jul 18, 2019 go to post

First two lines of your script should probably be user and password, unless you're running a minimal security install or enabled OS authentication.

ObjectScript code after that, yes, sothis looks correct

do ##class(User.Installer).setup()  

Maybe you need to load User.Installer beforehand?

Use $system.OBJ.Load(file, "c") to load and compile class(es) you need.

Eduard Lebedyuk · Jul 18, 2019 go to post

Sure

csession {INSTANCE} -U{NAMESPACE} < {SCRIPT}

Script contains code you want to execute, in your case the call to installer manifest. It could be a file or just the code itself.

Example.

A series of articles about automating CI/CD.

Eduard Lebedyuk · Jul 17, 2019 go to post

Fixed some issues in REST, but you have license problem.

ClassMethod CreateCoffee() As %Status
{

s json = {}.%FromJSON(%request.Data)
s CoffeeProp = ##class(User.PropertyName).%New()
s CoffeeProp.CoffeeName= json.CoffeeName
s CoffeeProp.CoffeeColor=json.CoffeeColor
s CoffeeProp.CoffeePrice= json.CoffeePrice
s Status = CoffeeProp.%Save()
}
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)