go to post Nezla · Jul 5, 2022 Thanks Robert but if you check my code above I already used csv and also tried 100 and still the same I get a tab delimited file rather than comma delimited that makes the columns glued to each other as in all columns as in one column (see attached below) see the file in a notepad and also the double quotes doesn't seems to work, the heading still includes the datatype Thanks
go to post Nezla · Jun 5, 2022 Hmmm, I was able to connect to their dev server with no issues, not sure it they use the same server for both Dev & live environments !? is there a path or a hotfix that I can run to upgrade TLS because upgrading Ensemble is not an option for the time being? Thanks
go to post Nezla · Jun 1, 2022 Never mind guys found the problem, i missed to put quit with a stauts as required (Quit $$$OK) Method OnTask() As %Status{S res= myclasdsQuit $$$OK}
go to post Nezla · May 30, 2022 Thanks Cristiano for you help. By the way do I need to add : D File.Open('R') before using copy From or just initialising the file is enough? Thx
go to post Nezla · May 28, 2022 I mean, just to put it simple and foget my code, how would you a post HTTPREQUEST for a JSON file given a file path? Thanks
go to post Nezla · May 28, 2022 So should I me converting my file into a %GlobalBinaryStream ? how can Correct my code because I'm not sure where or how to use %Save()? thanks
go to post Nezla · May 27, 2022 I already did but with no luck. But not sure why previous colleague hwo let the company is using %Net.MIMEPart, I haven't used this before I thought I need to send the JSON file is something like this: Set stream=##class(%FileBinaryStream).%New() Set stream.Filename=FilePath Do stream.LinkToFile(FilePath) if (CallbackHost ["VIBRA-API-DEV.AZUREWEBSITES.NET") { Set Httprequest=##class(%Net.HttpRequest).%New() Set Httprequest.SSLConfiguration="RTLS" Set Httprequest.Server="vibra-api-dev.azurewebsites.net" Set Httprequest.Timeout=30 Set Httprequest.Https=1 set Httprequest.ContentType="application/json" Do Httprequest.SetHeader("Accept","application/json") Do Httprequest.SetHeader("Accept-Language","en_US") Do Httprequest.SetHeader("Authorization","Bearer "_^Token) D Httprequest.EntityBody.Write(stream) Set tSc=Httprequest.Post("/API/SENSORS/VIBRATION") //S Out=Httprequest.HttpResponse.Data.ReadLine() Set StateCode=Httprequest.HttpResponse.StatusCode Quit StateCode would this work? thanks
go to post Nezla · May 27, 2022 Not 100% sure but I think it should be a JSON format so how can I change my code for JSON? sorry I'm a newbie, what do you mean encoding are referring to "text/plain" or "application/JSON" for example? Thanks
go to post Nezla · May 26, 2022 So in the future and in case I really need create a record with the same description on a unique indexed field, can I remove the UniqueIndex definition from the class definition do my change then put it back and compile rather than doing it through globals? also when rebuilding indexes from SMP, it says running at the background but there no notification when the rebuild has finished, is there a way to see the running process because I couldn't see it in Processes? Thanks
go to post Nezla · May 24, 2022 Hi Julius, Pls ignore my last message, I was just trying to attach a file to my message but didn't work. Thanks
go to post Nezla · May 24, 2022 what I sent is just a part of the full JSON as an example so it's not because it's missing part of it here is the full string, where I had to remove the brackets from beginning and end JSON [{"routeGuid":"531318d8-9967-445a-ae42-14e04244e0fb","sensorType":"MEMS TRIAXIAL","startDateTime":"2022-05-20T23:04:51.159Z","myProperty":0,"callbackHost":"https://vibra-api-dev.azurewebsites.net/api/sensors/vibration","collectionQuantity":1,"collectionInterval":0,"collectionTimeout":28140,"locationName":"Test Plant 1","locationGuid":"286c2dac-597d-41b0-8f6e-55f19fce9a9e","sensors":[{"equipmentName":"TestAsset 1","equipmentGuid":"ca62ff12-37fe-47a3-a315-95a4c011d835","componentName":"TestMOTORComponent 1","componentGuid":"3a291bf6-1ffd-4e14-b265-4b973c7660df","jobGUID":"0b955ee7-9a54-4b13-9af1-7019721faeab","sensorId":"MY0088","sampleRate":5000,"numberOfSamples":30000},{"equipmentName":"TestAsset 1","equipmentGuid":"ca62ff12-37fe-47a3-a315-95a4c011d835","componentName":"TestMOTORComponent 1","componentGuid":"3a291bf6-1ffd-4e14-b265-4b973c7660df","jobGUID":"8f9e85ab-31e7-4835-8969-6d72d142a2f1","sensorId":"MY0087","sampleRate":5000,"numberOfSamples":30000},{"equipmentName":"TestAsset 1","equipmentGuid":"ca62ff12-37fe-47a3-a315-95a4c011d835","componentName":"TestMOTORComponent 1","componentGuid":"3a291bf6-1ffd-4e14-b265-4b973c7660df","jobGUID":"68cea9d3-54cd-43f2-ae37-aaf47ed43e6b","sensorId":"001011","sampleRate":5000,"numberOfSamples":30000},{"equipmentName":"TestAsset 1","equipmentGuid":"ca62ff12-37fe-47a3-a315-95a4c011d835","componentName":"TestMOTORComponent 1","componentGuid":"3a291bf6-1ffd-4e14-b265-4b973c7660df","jobGUID":"7602764e-8951-451f-9653-ceb84834a1a6","sensorId":"001001","sampleRate":5000,"numberOfSamples":30000}]},{"routeGuid":"8c9d66f8-b6ff-4eba-9529-c4aec6443751","sensorType":"MEMS TRIAXIAL","startDateTime":"2022-05-20T15:04:51.159Z","myProperty":0,"callbackHost":"https://vibra-api-dev.azurewebsites.net/api/sensors/vibration","collectionQuantity":1,"collectionInterval":0,"collectionTimeout":28140,"locationName":"Test Plant 1","locationGuid":"286c2dac-597d-41b0-8f6e-55f19fce9a9e","sensors":[{"equipmentName":"TestAsset 1","equipmentGuid":"ca62ff12-37fe-47a3-a315-95a4c011d835","componentName":"TestMOTORComponent 1","componentGuid":"3a291bf6-1ffd-4e14-b265-4b973c7660df","jobGUID":"88d2e472-a1e4-40b3-a108-f2d32a2023e5","sensorId":"MY0088","sampleRate":5000,"numberOfSamples":30000},{"equipmentName":"TestAsset 1","equipmentGuid":"ca62ff12-37fe-47a3-a315-95a4c011d835","componentName":"TestMOTORComponent 1","componentGuid":"3a291bf6-1ffd-4e14-b265-4b973c7660df","jobGUID":"116f2ac6-da5f-46da-a7c7-92d9eaf98c89","sensorId":"MY0087","sampleRate":5000,"numberOfSamples":30000},{"equipmentName":"TestAsset 1","equipmentGuid":"ca62ff12-37fe-47a3-a315-95a4c011d835","componentName":"TestMOTORComponent 1","componentGuid":"3a291bf6-1ffd-4e14-b265-4b973c7660df","jobGUID":"a878e527-f519-4aaa-bf5d-0d65f72de119","sensorId":"001011","sampleRate":5000,"numberOfSamples":30000},{"equipmentName":"TestAsset 1","equipmentGuid":"ca62ff12-37fe-47a3-a315-95a4c011d835","componentName":"TestMOTORComponent 1","componentGuid":"3a291bf6-1ffd-4e14-b265-4b973c7660df","jobGUID":"be570b14-0555-4b86-ab9f-e37c40c79216","sensorId":"001001","sampleRate":5000,"numberOfSamples":30000}]},{"routeGuid":"2c661016-ebbd-4f26-b8e0-1ef63dc0b473","sensorType":"MEMS TRIAXIAL","startDateTime":"2022-05-20T07:04:51.159Z","myProperty":0,"callbackHost":"https://vibra-api-dev.azurewebsites.net/api/sensors/vibration","collectionQuantity":1,"collectionInterval":0,"collectionTimeout":28140,"locationName":"Test Plant 1","locationGuid":"286c2dac-597d-41b0-8f6e-55f19fce9a9e","sensors":[{"equipmentName":"TestAsset 1","equipmentGuid":"ca62ff12-37fe-47a3-a315-95a4c011d835","componentName":"TestMOTORComponent 1","componentGuid":"3a291bf6-1ffd-4e14-b265-4b973c7660df","jobGUID":"3a13e243-d6ed-4788-98b2-52e9213bee00","sensorId":"MY0088","sampleRate":5000,"numberOfSamples":30000},{"equipmentName":"TestAsset 1","equipmentGuid":"ca62ff12-37fe-47a3-a315-95a4c011d835","componentName":"TestMOTORComponent 1","componentGuid":"3a291bf6-1ffd-4e14-b265-4b973c7660df","jobGUID":"54969869-c4f6-43f6-a74a-2a67f9a73fc5","sensorId":"MY0087","sampleRate":5000,"numberOfSamples":30000},{"equipmentName":"TestAsset 1","equipmentGuid":"ca62ff12-37fe-47a3-a315-95a4c011d835","componentName":"TestMOTORComponent 1","componentGuid":"3a291bf6-1ffd-4e14-b265-4b973c7660df","jobGUID":"700af7d3-77b3-4a84-ba11-ea49602d6558","sensorId":"001011","sampleRate":5000,"numberOfSamples":30000},{"equipmentName":"TestAsset 1","equipmentGuid":"ca62ff12-37fe-47a3-a315-95a4c011d835","componentName":"TestMOTORComponent 1","componentGuid":"3a291bf6-1ffd-4e14-b265-4b973c7660df","jobGUID":"18dc3370-c291-468b-af1f-0361d95bb02c","sensorId":"001001","sampleRate":5000,"numberOfSamples":30000}]},{"routeGuid":"8e11ea63-be68-4283-91a3-6586eb1172b3","sensorType":"MEMS TRIAXIAL","startDateTime":"2022-05-19T23:04:51.159Z","myProperty":0,"callbackHost":"https://vibra-api-dev.azurewebsites.net/api/sensors/vibration","collectionQuantity":1,"collectionInterval":0,"collectionTimeout":28140,"locationName":"Test Plant 1","locationGuid":"286c2dac-597d-41b0-8f6e-55f19fce9a9e","sensors":[{"equipmentName":"TestAsset 1","equipmentGuid":"ca62ff12-37fe-47a3-a315-95a4c011d835","componentName":"TestMOTORComponent 1","componentGuid":"3a291bf6-1ffd-4e14-b265-4b973c7660df","jobGUID":"35d0d2e7-1199-4c18-8941-4fff6dbdba1f","sensorId":"MY0088","sampleRate":5000,"numberOfSamples":30000},{"equipmentName":"TestAsset 1","equipmentGuid":"ca62ff12-37fe-47a3-a315-95a4c011d835","componentName":"TestMOTORComponent 1","componentGuid":"3a291bf6-1ffd-4e14-b265-4b973c7660df","jobGUID":"8044560c-94d2-4da7-87f5-07328d9e62c1","sensorId":"MY0087","sampleRate":5000,"numberOfSamples":30000},{"equipmentName":"TestAsset 1","equipmentGuid":"ca62ff12-37fe-47a3-a315-95a4c011d835","componentName":"TestMOTORComponent 1","componentGuid":"3a291bf6-1ffd-4e14-b265-4b973c7660df","jobGUID":"b636a2f5-d35f-4c82-9646-e09572336e23","sensorId":"001011","sampleRate":5000,"numberOfSamples":30000},{"equipmentName":"TestAsset 1","equipmentGuid":"ca62ff12-37fe-47a3-a315-95a4c011d835","componentName":"TestMOTORComponent 1","componentGuid":"3a291bf6-1ffd-4e14-b265-4b973c7660df","jobGUID":"9c9a4bf4-e8af-4b8d-9de2-a99cdff150ed","sensorId":"001001","sampleRate":5000,"numberOfSamples":30000}]},{"routeGuid":"b8e5e096-c9bc-41c5-a1af-713301cb7545","sensorType":"MEMS TRIAXIAL","startDateTime":"2022-05-19T15:04:51.159Z","myProperty":0,"callbackHost":"https://vibra-api-dev.azurewebsites.net/api/sensors/vibration","collectionQuantity":1,"collectionInterval":0,"collectionTimeout":28140,"locationName":"Test Plant 1","locationGuid":"286c2dac-597d-41b0-8f6e-55f19fce9a9e","sensors":[{"equipmentName":"TestAsset 1","equipmentGuid":"ca62ff12-37fe-47a3-a315-95a4c011d835","componentName":"TestMOTORComponent 1","componentGuid":"3a291bf6-1ffd-4e14-b265-4b973c7660df","jobGUID":"a576d235-6eb6-4312-a1ff-7b1f767b88ce","sensorId":"MY0088","sampleRate":5000,"numberOfSamples":30000},{"equipmentName":"TestAsset 1","equipmentGuid":"ca62ff12-37fe-47a3-a315-95a4c011d835","componentName":"TestMOTORComponent 1","componentGuid":"3a291bf6-1ffd-4e14-b265-4b973c7660df","jobGUID":"654cf21e-daad-4a11-b676-86a7bc8a3360","sensorId":"MY0087","sampleRate":5000,"numberOfSamples":30000},{"equipmentName":"TestAsset 1","equipmentGuid":"ca62ff12-37fe-47a3-a315-95a4c011d835","componentName":"TestMOTORComponent 1","componentGuid":"3a291bf6-1ffd-4e14-b265-4b973c7660df","jobGUID":"2be4efc8-6616-4bff-87ba-30fe388a1b34","sensorId":"001011","sampleRate":5000,"numberOfSamples":30000},{"equipmentName":"TestAsset 1","equipmentGuid":"ca62ff12-37fe-47a3-a315-95a4c011d835","componentName":"TestMOTORComponent 1","componentGuid":"3a291bf6-1ffd-4e14-b265-4b973c7660df","jobGUID":"a5374d6c-311c-44d0-8d06-3a31f33dd3a8","sensorId":"001001","sampleRate":5000,"numberOfSamples":30000}]},{"routeGuid":"9ea2968a-8deb-480c-9591-ffa18760b87f","sensorType":"MEMS TRIAXIAL","startDateTime":"2022-05-21T07:04:51.159Z","myProperty":0,"callbackHost":"https://vibra-api-dev.azurewebsites.net/api/sensors/vibration","collectionQuantity":1,"collectionInterval":0,"collectionTimeout":28140,"locationName":"Test Plant 1","locationGuid":"286c2dac-597d-41b0-8f6e-55f19fce9a9e","sensors":[{"equipmentName":"TestAsset 1","equipmentGuid":"ca62ff12-37fe-47a3-a315-95a4c011d835","componentName":"TestMOTORComponent 1","componentGuid":"3a291bf6-1ffd-4e14-b265-4b973c7660df","jobGUID":"955529c5-36be-4f3e-b768-0e3b377804a7","sensorId":"001011","sampleRate":5000,"numberOfSamples":30000},{"equipmentName":"TestAsset 1","equipmentGuid":"ca62ff12-37fe-47a3-a315-95a4c011d835","componentName":"TestMOTORComponent 1","componentGuid":"3a291bf6-1ffd-4e14-b265-4b973c7660df","jobGUID":"60a7cdb0-499e-4d02-b4d3-06ee58e40481","sensorId":"001001","sampleRate":5000,"numberOfSamples":30000},{"equipmentName":"TestAsset 1","equipmentGuid":"ca62ff12-37fe-47a3-a315-95a4c011d835","componentName":"TestMOTORComponent 1","componentGuid":"3a291bf6-1ffd-4e14-b265-4b973c7660df","jobGUID":"e84eda78-1491-49af-9e34-d647e817a251","sensorId":"MY0087","sampleRate":5000,"numberOfSamples":30000},{"equipmentName":"TestAsset 1","equipmentGuid":"ca62ff12-37fe-47a3-a315-95a4c011d835","componentName":"TestMOTORComponent 1","componentGuid":"3a291bf6-1ffd-4e14-b265-4b973c7660df","jobGUID":"9bcd5fe6-6f05-4482-ad78-612f35c60b41","sensorId":"MY0088","sampleRate":5000,"numberOfSamples":30000}]}]
go to post Nezla · May 18, 2022 Nope, changed it to */* and didn't make any diffrence. in the Token there are "." & "_" special charachters not sure if that cause problem, I tried removed them but still no luck.
go to post Nezla · May 17, 2022 mybe you mean this d ##class(%ZEN.Auxiliary.jsonProvider).%ConvertJSONToObject(SampleJsonData,,.list) ,I tried that but I got an empty list? in all cases, after doing the below, I should be able at lease read the JSON string but I'm getting an html file, so I'm missing something in my code? set Httprequest = ##class(%Net.HttpRequest).%New() Set Httprequest.SSLConfiguration="RTLS" Set Httprequest.Server="serverurl" Set Httprequest.Https=1 Set Httprequest.Timeout=30 set Httprequest.ContentType="application/json" Do Httprequest.SetHeader("Accept","text/plain") set Httprequest.Username="user" set Httprequest.Password="password" S stat= Httprequest.Get("someurl") Set Resp=Httprequest.HttpResponse.Data.Read()
go to post Nezla · May 17, 2022 So I did the following from the Terminal: set Httprequest = ##class(%Net.HttpRequest).%New() Set Httprequest.SSLConfiguration="RTLS" Set Httprequest.Server="serverurl" Set Httprequest.Https=1 Set Httprequest.Timeout=30 set Httprequest.ContentType="application/json" Do Httprequest.SetHeader("Accept","text/plain") set Httprequest.Username="user" set Httprequest.Password="password" S stat= Httprequest.Get("someurl") W stat1 so given the status =1 that means everything went ok isn't if not how can I check? then I did the following to read the JSON file : Set Resp=Httprequest.HttpResponse.Data.Read() but when I cheked what's in Resp I get the below html output: <!DOCTYPE html><html><head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" /> <title>IUDEX</title> <base href="/" /> <link href="_content/MudBlazor/MudBlazor.min.css" rel="stylesheet" /> <link href="_content/Smart.Blazor/css/smart.default.css" rel="stylesheet" /> <link href="css/app.css" rel="stylesheet" /> <link href="Galaxy.Client.styles.css" rel="stylesheet" /></head><body> <style> .loader-logo { width: 256px; } .loader-container { flex-direction: column; flex-wrap: nowrap; justify-content: center; align-items: center; display: flex; gap: 32px; height: 512px; } .spinner { border: 5px solid #afafaf; border-top: 5px solid #e53947; border-radius: 50%; width: 32px; height: 32px; animation: spin 700ms linear infinite; } @keyframes spin { 0% { transform: rotate(0deg) } 100% { transform: rotate(360deg) } } </style> <div class="loader-container" id="app"> <img class="loader-logo" src="images/logo-dark.svg" /> <div class="spinner"></div> <div id="blazor-error-ui"> An unhandled error has occurred. <a href="" class="reload">Reload</a> <a class="dismiss">ð</a> </div> </div> <script src="_content/MudBlazor/MudBlazor.min.js"></script> <script src="_content/Smart.Blazor/js/smart.blazor.js"></script> <script src="_content/Smart.Blazor/js/smart.elements.js"></script> <script src="_content/Galaxy.DataViewer/canvasjs.min.js"></script> <script src="_framework/blazor.webassembly.js"></script> <script src="js/galaxyLib.min.js"></script> </body></html> I thought I'll be getting a JSON string, FYI I'm supposed to a get a Token in a JSON file? Thanks
go to post Nezla · May 17, 2022 sorry also set obj = {}.%FromJSON(req.HttpResponse.Data) is not working, is this available in Ensemble 2014? Thanks
go to post Nezla · May 17, 2022 Hi Set jsonObject={}.%FromJSON(jsonString) doesn't seems to work and couldn't find %FromJSON in Docs is this available in Ensemble 2014 which I'm using? thanks