go to post Carina Mueler · Sep 9, 2018 It has nothing to do with the properties.If I first create the properties in Atelier and then send the data with python to my database.. it throws the same error and the data is there..
go to post Carina Mueler · Sep 8, 2018 https://docs.intersystems.com/latest/csp/docbook/DocBook.UI.Page.cls?KEY..."Error messages 500 through 699: None. Error messages 700 through 799: "
go to post Carina Mueler · Sep 8, 2018 I had this before too, but the data is there. One cell of my data is empty (the first one) an this could be the error, but it's no problem for now. It has nothing to do with the properties I think..
go to post Carina Mueler · Sep 8, 2018 The full answer is:(Verbindung erfolgreich = Connection successDaten erhalten = load data)
go to post Carina Mueler · Sep 8, 2018 OK, sorry, it does create the database but still not the property :( url = "http://127.0.0.1:52773/api/docdb/v1/DEMO/db/Demo.TEST11" header = { 'Content-Type': 'application/json', } def getPropertyUrl(property, host = "127.0.0.1", port = 52773, namespace = "DEMO", db = "DEMO.TEST11"): return "http://{}:{}/api/docdb/v1/{}/prop/{}/{}" .format(*[host, port, namespace, db, property]) def main(): session = requests.Session() session.auth = ("_SYSTEM", "SYS") response = session.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()) That is my code now, but the result is still as the screenshot above..
go to post Carina Mueler · Sep 8, 2018 It actually doesn't create neither database or property. Something is wrong. And if I have 20 properties... this would be a long code right?
go to post Carina Mueler · Sep 8, 2018 Hi Eduard, thank you for your answer. I do know how to call it, but I don't know where schould I add it. Should I add the url in the header or should I create a new header - header2 - and separate it with comma from 'Content-Type': 'application/json' or how can I call it in my code that I shared: url = "http://127.0.0.1:52773/api/docdb/v1/NamespaceName/db/DBName" url2 = "http://127.0.0.1:52773/api/docdb/v1/NamespaceName/doc/DBName/" header = { 'Content-Type': 'application/json', } 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 = requests.post(url, headers=header) print(response.status_code) else: print('DB found, load data...') Can you please add the following urls in my code at the right place? http://127.0.0.1:52773/api/docdb/v1/NamespaceName/db/DBName/Ergebniszuf?type=%Numeric&path=Ergebniszuf&unique=0 http://127.0.0.1:52773/api/docdb/v1/NamespaceName/db/DBName/Jahr?type=%Integer&path=Jahr&unique=0 Thank you in advance
go to post Carina Mueler · Jul 14, 2018 What is the difference for example between Ensemble and IRIS ans Cache?
go to post Carina Mueler · Jul 7, 2018 Hi, thank you for your response @Robert Camper!set filename = "path/to/file.json" <- here is my path, for example /home/test.jsonThat was not the problem. I didn't find the problem in my code.Anyway I have changed my code to:Class User.MyClass Extends %CSP.REST{XData UrlMap [ XMLNamespace = "http://www.intersystems.com/urlmap" ]{<Routes><Route Url="/test" Method="GET" Call="getFile" /></Routes>}ClassMethod getFile() as %Status{ set filename = "/home/test.json" set newArray={}.%FromJSON(filename) write "New entity:"_newArray.%ToJSON() }and I become the output, but at the end there is an error:[" zDispatchRequest+42^%CSP.REST.1 *Function must return a value at zgetFile+4^User.MyClass.1" ] } ], "summary":"ERROR #5002: Cache error: zDispatchRequest+42^%CSP.REST.1 *Function must return a value at zgetFile+4^User.MyClass.1" }Do you know what does it mean?
go to post Carina Mueler · Jul 6, 2018 I just try some examples from the documentation.ClassMethod getFile() as %Persistent{ set filename = "path/to/file.json" set stream = ##class(%Stream.FileCharacter).%New() set sc = stream.LinkToFile(filename) set obj = ##class(%DynamicAbstractObject).%FromJSON(stream) set jsonObj = [].%FromJSON(filename) set i = jsonObj.resultSets.%GetIterator() while i.%GetNext(.key , .resultSet ) { set i2 = resultSet.rowSet.%GetIterator() write resultSet.name,! while i2.%GetNext(.key , .rowSet ) { write rowSet.%Get(0),! }}So, row 8 is: set obj = ##class(%DynamicAbstractObject).%FromJSON(stream)