Eduard Lebedyuk · Sep 14, 2018 go to post

What does it actually do?

I have a table SQLUser.Person for example, it returns nothing.

Eduard Lebedyuk · Sep 13, 2018 go to post

Try application/xml instead of text/xml for content type.

If it does not help, check API docs for correct type.

For accept try */*.

Eduard Lebedyuk · Sep 11, 2018 go to post

I think I encountered something similar. I added to target class:

Class Proxy.Class Extends (%Persistent, %XML.Adaptor) {

Parameter XMLIGNOREINVALIDTAG =1;

Parameter XMLIGNOREINVALIDATTRIBUTE= 1;
...

}

And it helped.

Eduard Lebedyuk · Sep 8, 2018 go to post

201 looks like a correct response.

500 on the other hand is an error. Check what's the error.

Eduard Lebedyuk · Sep 8, 2018 go to post

What's the status_code on

            response = session.post(getPropertyUrl(property), params= {"type":"%Numeric", "path": property, "unique":0}, headers=header)
            print(response.status_code)
Eduard Lebedyuk · Sep 8, 2018 go to post

It actually doesn't create neither database or property.

Check that %Service_DocDB is enabled. Your screenshot also shows that database gets created.

if I have 20 properties... this would be a long code

You need to cycle over all properties, so +2 lines probably.

Eduard Lebedyuk · Sep 8, 2018 go to post

Made an erro in URL, it's not  .../db/DBName/Propname but .../prop/db/DBName/Propname.

Here's a sample code that creates a db and a property.

import requests

def getBaseUrl(host = "127.0.0.1", port = 52773,  namespace = "user", db = "test"):
    return "http://{}:{}/api/docdb/v1/{}/db/{}" .format(*[host, port, namespace, db])

def getPropertyUrl(property, host = "127.0.0.1", port = 52773,  namespace = "user", db = "test"):
    return "http://{}:{}/api/docdb/v1/{}/prop/{}/{}" .format(*[host, port, namespace, db, property])

def main():

    url = getBaseUrl()
    print(url)
    header = {
        'Content-Type': 'application/json',
    }

    session = requests.Session()
    session.auth = ("_SYSTEM", "SYS")

    response = session.get(url, headers=header)
    #response = requests.get(url, headers=header)
print(response.status_code)  # Number of error
if response.status_code == 404:
        print('DB not found, create DB ...')
        response = session.post(url, headers=header)
        print(response.status_code)
    elif response.status_code != 200:
        print('Unknown error: ' + response.status_code + ' ' + response.reason)
    else:
        property = "Ergebniszuf"
# check that property exist
response = session.get(getPropertyUrl(property), headers=header)

        if response.status_code == 404:
            print('Property not found, creating property: ' + property)
            response = session.post(getPropertyUrl(property), params= {"type":"%Numeric", "path": property, "unique":0}, headers=header)
            print(response)
        elif response.status_code != 200:
            print('Unknown error: ' + response.status_code + ' ' + response.reason)
        else:

            print('DB found, load data...')

    return 1
if __name__ == '__main__':
    print(main())
Eduard Lebedyuk · Sep 8, 2018 go to post

2012.1.4 has JSON support via %ZEN.proxyObject

set obj = ##class(%ZEN.proxyObject).%New()
set obj.createTransactionRequest= ##class(%ZEN.proxyObject).%New()
set obj.createTransactionRequest.merchantAuthentication = ##class(%ZEN.proxyObject).%New()
set obj.createTransactionRequest.merchantAuthentication.name = "gfufet9QVgT5P"
do obj.%ToJSON()

Also you can use %ZEN.Auxiliary.jsonProvider to convert object into JSON.

Eduard Lebedyuk · Sep 7, 2018 go to post

To create one property call:

http://127.0.0.1:52773/api/docdb/v1/NamespaceName/db/DBName/propertyName?type=propertyType&path=propertyPath&unique=propertyUnique

You'll need one call per property.

For your property Ergebniszuf, url would be:

http://127.0.0.1:52773/api/docdb/v1/NamespaceName/db/DBName/Ergebniszuf?type=%String&path=Ergebniszuf&unique=0
Eduard Lebedyuk · Sep 7, 2018 go to post

Interesting. Check this article - I think you'll need either HTTP Debugging proxy (probably) or Packet analyzer (maybe) to debug this further.

As you have reference implementation (Postman) you can start by comparing Postman request/response and Ensemble request/response using HTTP Debugging proxy.

Eduard Lebedyuk · Sep 7, 2018 go to post

When you get sc=1 , what about:

set resp=httpRequest.HttpResponsezw resp
do resp.Data.OutputToDevice()
Eduard Lebedyuk · Sep 7, 2018 go to post

Compare output of

Set sc = httpRequest.Post("/sample/", 1)

with what Postman sends.

Also, what does

Set sc = httpRequest.Post("/sample/")
zw sc

show?

Eduard Lebedyuk · Sep 6, 2018 go to post

Continuous Delivery - what tools do you use to automate building, testing and deploying your applications?  Do you integrate issue tools/messaging/planning and CD tools?

Eduard Lebedyuk · Sep 6, 2018 go to post

Just add empty string as is:

ClassMethod Test(val = "")
{
 Set t = ##class(Forerun.Test).%New()
 Do t.ReviewedBy.Insert(val)
 $$$THROWONERROR(tSC, t.%Save())
 Set id = t.%Id()
 Set user = "me"
 &SQL(UPDATE Test.Test
            SET ReviewedBy = ReviewedBy||$ListBuild(:user)
            WHERE ID=:id
            )
 If SQLCODE<0 Write "Problem",! Quit
}
Eduard Lebedyuk · Sep 6, 2018 go to post

Usually response does contain status information in StatusCode and StatusLine properties.

You need to change this line

Set httpResponse = httpRequest.Post("/sample/", 2)

to

#dim sc As %Status = $$$OK
Set sc = httpRequest.Post("/sample/", 2)Write $System.Status.GetErrorText(sc)

As Post method returns status.

After debugging you can use

write $$$ISERR(sc)

macro to check if result of some operation is an error.

Eduard Lebedyuk · Sep 6, 2018 go to post

The easiest solution would be

set net.SSLCheckServerIdentity=0

that disables server cert checking. Not very secure obviously.

Eduard Lebedyuk · Sep 5, 2018 go to post

Do you want to change ROWSPEC depending on passed argument?

ROWSPEC can be changed on compilation only and it's rather static. At least xDBC clients depend on declared schema/query info and so it cannot be changed dynamically.

Eduard Lebedyuk · Sep 5, 2018 go to post

it causes error messages as something in the class is not correct,

What error messages?

Also try calling

zwrite %objlasterror

it may contain additional information.

Eduard Lebedyuk · Sep 4, 2018 go to post

You can use methods of %Activate.TLEnumerator class to load libraries programmatically.

Eduard Lebedyuk · Sep 4, 2018 go to post

I think you'll need a full fledged orchestrator for that. Docker run always starts one container, bit several volumes could be mounted, some of them RW, some RO. I'm not sure about mounting the same folder into several containers (again, orchestration).

You can also use volumes_from argument to mount directory from one container to another.