Ask the Community
Groups
How to use JSON with Traverse? - Connect IT Community | Kaseya
<main> <article class="userContent"> <p><strong>QUESTION:</strong></p> <p>How to use JSON with Traverse?</p> <p> </p> <p><strong>RESOLUTION:</strong></p> <p>Traverse supports JSON requests for several SOAP Web Services endpoints.</p> <p>See <a href="/home/leaving?allowTrusted=1&target=http%3A%2F%2Fkaseyasupport.kaseyacloud.com%2Fapi.jsp">http://kaseyasupport.kaseyacloud.com/api.jsp</a></p> <p> </p> <p>In this example, we will get the test historical data for one test</p> <p><strong>NOTE: Replace </strong></p> <p>* <a href="/home/leaving?allowTrusted=1&target=http%3A%2F%2Fkaseyasupport.kaseyacloud.com">http://kaseyasupport.kaseyacloud.com</a> with the URL for your server</p> <p>* auser with the appropriate user</p> <p>* apassword with the appropriate password</p> <p> </p> <p><a href="/home/leaving?allowTrusted=1&target=http%3A%2F%2Fkaseyasupport.kaseyacloud.com%2Fapi%2Fjson%2Ftest%3F_wadl%26_type%3Dxml">http://kaseyasupport.kaseyacloud.com/api/json/test?_wadl&_type=xml</a></p> <p>We will use the getRawHistoricalData function</p> <h3 data-id="using-json-from-the-web-browser"><strong>Using JSON from the web browser:</strong></h3> <p>Install the 'Postman - Rest Client' extension - <a href="/home/leaving?allowTrusted=1&target=https%3A%2F%2Fchrome.google.com%2Fwebstore%2Fdetail%2Fpostman-rest-client%2Ffdmmgilgnpjigdojojpjoooidkmcomcm">https://chrome.google.com/webstore/detail/postman-rest-client/fdmmgilgnpjigdojojpjoooidkmcomcm</a></p> <p>Access the extension as in - chrome-extension://fdmmgilgnpjigdojojpjoooidkmcomcm/index.html</p> <p>Configure the settings as shown in this image here:</p> <p><img src="/attachments/token/JwlfiIMYuHzTAgg5EgEQMPg75/?name=postman.PNG" alt="postman.PNG" class="embedImage-img importedEmbed-img"></img></p> <p> To fill out the form:</p> <p>Specify the URL - <a href="/home/leaving?allowTrusted=1&target=http%3A%2F%2Fkaseyasupport.kaseyacloud.com%2Fapi%2Fjson%2Ftest%2FgetRawHistoricalData">http://kaseyasupport.kaseyacloud.com/api/json/test/getRawHistoricalData</a></p> <p>Pick POST from the dropdown</p> <p>Click Headers(0) - top right</p> <p>Click on the Header area in the Header Value pair</p> <p>Start typing acc and select Accept; for the Value, type application/json</p> <p>Click on the nextHeader area in the Header Value pair</p> <p>Start typing con and select Content-Type; for the Value, type application/json</p> <p> Click on raw</p> <p>In the drop down next to raw, select JSON</p> <p>Enter the data:</p> <div> <pre class="code codeBlock" spellcheck="false" tabindex="0">{ "username":"auser", "password":"apassword", "startTimeExp":"1-hours-ago", "endTimeExp":"now", "searchCriterias": [ { "searchOption": "TEST_SERIAL_NUMBER", "searchTerms": "990219" } ] } </pre> </div> <p>and click on Send</p> <p>The lower pane should populate with results as in:</p> <div> <pre class="code codeBlock" spellcheck="false" tabindex="0"> {"success":true,"errorCode":null,"errorMessage":null,"timestamp":1442024573243,"timestampStr":"Friday, 11 September 2015 19:22:53 o'clock PDT","result":{"historicalData":[{"testSerialNumber":990219,"deviceSerialNumber":990193,"accountSerialNumber":49,"testName":"Round Trip Time","deviceName":"DGE01","accountName":"Core Infrastructure","units":"ms","thresholdType":1,"percentile95":1.0,"percentile98":1.0,"minValue":1.0,"maxValue":1.0,"stdDev":0.0,"mean":1.0,"values":[{"timestamp":1442021095880,"minValue":1,"average":1,"maxValue":1,"warningThreshold":250,"criticalThreshold":1500,"maxSeverity":2048,"numSamples":1},{"timestamp":1442021395880,"minValue":1,"average":1,"maxValue":1,"warningThreshold":250,"criticalThreshold":1500,"maxSeverity":2048,"numSamples":2},{"timestamp":1442021695880,"minValue":1,"average":1,"maxValue":1,"warningThreshold":250,"criticalThreshold":1500,"maxSeverity":2048,"numSamples":2},{"timestamp":1442021995880,"minValue":1,"average":1,"maxValue":1,"warningThreshold":250,"criticalThreshold":1500,"maxSeverity":2048,"numSamples":1},{"timestamp":1442022295880,"minValue":1,"average":1,"maxValue":1,"warningThreshold":250,"criticalThreshold":1500,"maxSeverity":2048,"numSamples":2},{"timestamp":1442022595880,"minValue":1,"average":1,"maxValue":1,"warningThreshold":250,"criticalThreshold":1500,"maxSeverity":2048,"numSamples":2},{"timestamp":1442022895880,"minValue":1,"average":1,"maxValue":1,"warningThreshold":250,"criticalThreshold":1500,"maxSeverity":2048,"numSamples":1},{"timestamp":1442023195880,"minValue":1,"average":1,"maxValue":1,"warningThreshold":250,"criticalThreshold":1500,"maxSeverity":2048,"numSamples":2},{"timestamp":1442023495880,"minValue":1,"average":1,"maxValue":1,"warningThreshold":250,"criticalThreshold":1500,"maxSeverity":2048,"numSamples":2},{"timestamp":1442023795880,"minValue":1,"average":1,"maxValue":1,"warningThreshold":250,"criticalThreshold":1500,"maxSeverity":2048,"numSamples":1},{"timestamp":1442024095880,"minValue":1,"average":1,"maxValue":1,"warningThreshold":250,"criticalThreshold":1500,"maxSeverity":2048,"numSamples":2},{"timestamp":1442024395880,"minValue":1,"average":1,"maxValue":1,"warningThreshold":250,"criticalThreshold":1500,"maxSeverity":2048,"numSamples":2}]}]}} </pre> </div> <p> </p> <p> </p> <h3 data-id="using-json-with-curl-from-a-linux-prompt-looks-like"> <strong>Using JSON with curl from a Linux prompt looks like</strong>:</h3> <div> <pre class="code codeBlock" spellcheck="false" tabindex="0"> curl -k -i -H "Content-Type: application/json" -H "Accept: application/json" -X POST -d '{ "username":"auser", "password":"apassword", "startTimeExp":"1-hours-ago", "endTimeExp":"now", "searchCriterias": [ { "searchOption": "TEST_SERIAL_NUMBER", "searchTerms": "990219" } ] }' <a href="/home/leaving?allowTrusted=1&target=https%3A%2F%2Fkaseyasupport.kaseyacloud.com%2Fapi%2Fjson%2Ftest%2FgetRawHistoricalData">https://kaseyasupport.kaseyacloud.com/api/json/test/getRawHistoricalData</a> </pre> </div> <p>The response is</p> <div> <pre class="code codeBlock" spellcheck="false" tabindex="0"> HTTP/1.1 200 OK Server: Apache-Coyote/1.1 Set-Cookie: TraverseJSessionID=05C2A2024798AD20BB72A020CFA889AE; Path=/; HttpOnly Date: Sat, 12 Sep 2015 01:27:18 GMT Content-Type: application/json Content-Length: 2250 {"success":true,"errorCode":null,"errorMessage":null,"timestamp":1442021238429,"timestampStr":"Friday, 11 September 2015 18:27:18 o'clock PDT",<br>"result":{"historicalData":[{"testSerialNumber":990219,"deviceSerialNumber":990193,"accountSerialNumber":49,"testName":"Round Trip Time","deviceName":"DGE01",<br>"accountName":"Core Infrastructure","units":"ms","thresholdType":1,"percentile95":1.0,"percentile98":1.0,"minValue":1.0,"maxValue":1.0,"stdDev":0.0,"mean":1.0,"values":[<br>{"timestamp":1442017855880,"minValue":1,"average":1,"maxValue":1,"warningThreshold":250,"criticalThreshold":1500,"maxSeverity":2048,"numSamples":2},<br>{"timestamp":1442018155880,"minValue":1,"average":1,"maxValue":1,"warningThreshold":250,"criticalThreshold":1500,"maxSeverity":2048,"numSamples":1},<br>{"timestamp":1442018455880,"minValue":1,"average":1,"maxValue":1,"warningThreshold":250,"criticalThreshold":1500,"maxSeverity":2048,"numSamples":2},<br>{"timestamp":1442018755880,"minValue":1,"average":1,"maxValue":1,"warningThreshold":250,"criticalThreshold":1500,"maxSeverity":2048,"numSamples":2},<br>{"timestamp":1442019055880,"minValue":1,"average":1,"maxValue":1,"warningThreshold":250,"criticalThreshold":1500,"maxSeverity":2048,"numSamples":1},<br>{"timestamp":1442019355880,"minValue":1,"average":1,"maxValue":1,"warningThreshold":250,"criticalThreshold":1500,"maxSeverity":2048,"numSamples":2},<br>{"timestamp":1442019655880,"minValue":1,"average":1,"maxValue":1,"warningThreshold":250,"criticalThreshold":1500,"maxSeverity":2048,"numSamples":2},<br>{"timestamp":1442019955880,"minValue":1,"average":1,"maxValue":1,"warningThreshold":250,"criticalThreshold":1500,"maxSeverity":2048,"numSamples":1},<br>{"timestamp":1442020255880,"minValue":1,"average":1,"maxValue":1,"warningThreshold":250,"criticalThreshold":1500,"maxSeverity":2048,"numSamples":2},<br>{"timestamp":1442020555880,"minValue":1,"average":1,"maxValue":1,"warningThreshold":250,"criticalThreshold":1500,"maxSeverity":2048,"numSamples":2},<br>{"timestamp":1442020855880,"minValue":1,"average":1,"maxValue":1,"warningThreshold":250,"criticalThreshold":1500,"maxSeverity":2048,"numSamples":1},<br>{"timestamp":1442021155880,"minValue":1,"average":1,"maxValue":1,"warningThreshold":250,"criticalThreshold":1500,"maxSeverity":2048,"numSamples":1}]}]}} </pre> </div> <p> </p> <h3 data-id="using-json-on-windows-curl-for-windows-has-been-installed-before-hand-note-that-to-account-for-special-characters-the-data"><strong>Using JSON on Windows (curl for Windows has been installed before hand); note that to account for special characters the data</strong></h3> <div> <pre class="code codeBlock" spellcheck="false" tabindex="0"> { "username":"auser", "password":"apassword", "startTimeExp":"1-hours-ago", "endTimeExp":"now", "searchCriterias": [ { "searchOption": "TEST_SERIAL_NUMBER", "searchTerms": "990219" } ] } </pre> </div> <p>needed to be in a file (c:\post.txt in the example below). The command used is</p> <div> <pre class="code codeBlock" spellcheck="false" tabindex="0"> C:\Users\piyush.mehta>curl -i -H "Content-Type: application/json" -H "Accept: application/json" -X POST -d <a href="https://kaseya.vanillacommunities.com/profile/c" rel="nofollow">@c</a>:\post.txt <a href="/home/leaving?allowTrusted=1&target=http%3A%2F%2Fkaseyasupport.kaseyacloud.com%2Fapi">http://kaseyasupport.kaseyacloud.com/api</a> /json/test/getRawHistoricalData </pre> </div> <p>with the results</p> <div> <pre class="code codeBlock" spellcheck="false" tabindex="0"> HTTP/1.1 200 OK Server: Apache-Coyote/1.1 Set-Cookie: TraverseJSessionID=28E29484E48894C30087191BE3E85849; Path=/; HttpOnly Date: Sat, 12 Sep 2015 01:34:15 GMT Content-Type: application/json Content-Length: 2250 {"success":true,"errorCode":null,"errorMessage":null,"timestamp":1442021655381,"timestampStr":"Friday, 11 September 2015 18:34:15 o'clock PDT","result":{"histor icalData":[{"testSerialNumber":990219,"deviceSerialNumber":990193,"accountSerialNumber":49,"testName":"Round Trip Time","deviceName":"DGE01","accountName":"Core Infrastructure","units":"ms","thresholdType":1,"percentile95":1.0,"percentile98":1.0,"minValue":1.0,"maxValue":1.0,"stdDev":0.0,"mean":1.0,"values":[{"timestam p":1442018215881,"minValue":1,"average":1,"maxValue":1,"warningThreshold":250,"criticalThreshold":1500,"maxSeverity":2048,"numSamples":1},{"timestamp":144201851 5881,"minValue":1,"average":1,"maxValue":1,"warningThreshold":250,"criticalThreshold":1500,"maxSeverity":2048,"numSamples":2},{"timestamp":1442018815881,"minVal ue":1,"average":1,"maxValue":1,"warningThreshold":250,"criticalThreshold":1500,"maxSeverity":2048,"numSamples":2},{"timestamp":1442019115881,"minValue":1,"avera ge":1,"maxValue":1,"warningThreshold":250,"criticalThreshold":1500,"maxSeverity":2048,"numSamples":1},{"timestamp":1442019415881,"minValue":1,"average":1,"maxVa lue":1,"warningThreshold":250,"criticalThreshold":1500,"maxSeverity":2048,"numSamples":2},{"timestamp":1442019715881,"minValue":1,"average":1,"maxValue":1,"warn ingThreshold":250,"criticalThreshold":1500,"maxSeverity":2048,"numSamples":2},{"timestamp":1442020015881,"minValue":1,"average":1,"maxValue":1,"warningThreshold ":250,"criticalThreshold":1500,"maxSeverity":2048,"numSamples":1},{"timestamp":1442020315881,"minValue":1,"average":1,"maxValue":1,"warningThreshold":250,"criti calThreshold":1500,"maxSeverity":2048,"numSamples":2},{"timestamp":1442020615881,"minValue":1,"average":1,"maxValue":1,"warningThreshold":250,"criticalThreshold ":1500,"maxSeverity":2048,"numSamples":2},{"timestamp":1442020915881,"minValue":1,"average":1,"maxValue":1,"warningThreshold":250,"criticalThreshold":1500,"maxS everity":2048,"numSamples":1},{"timestamp":1442021215881,"minValue":1,"average":1,"maxValue":1,"warningThreshold":250,"criticalThreshold":1500,"maxSeverity":204 8,"numSamples":2},{"timestamp":1442021515881,"minValue":1,"average":1,"maxValue":1,"warningThreshold":250,"criticalThreshold":1500,"maxSeverity":2048,"numSample s":1}]}]}} </pre> </div> <p>{ "success": true, "errorCode": null, "errorMessage": null, "timestamp": 1442021238429, "timestampStr": "Friday, 11 September 2015 18:27:18 o'clock PDT", "result": { "historicalData": [ { "testSerialNumber": 990219, "deviceSerialNumber": 990193, "accountSerialNumber": 49, "testName": "Round Trip Time", "deviceName": "DGE01", "accountName": "Core Infrastructure", "units": "ms", "thresholdType": 1, "percentile95": 1.0, "percentile98": 1.0, "minValue": 1.0, "maxValue": 1.0, "stdDev": 0.0, "mean": 1.0, "values": [ { "timestamp": 1442017855880, "minValue": 1, "average": 1, "maxValue": 1, "warningThreshold": 250, "criticalThreshold": 1500, "maxSeverity": 2048, "numSamples": 2 }, { "timestamp": 1442018155880, "minValue": 1, "average": 1, "maxValue": 1, "warningThreshold": 250, "criticalThreshold": 1500, "maxSeverity": 2048, "numSamples": 1 }, { "timestamp": 1442018455880, "minValue": 1, "average": 1, "maxValue": 1, "warningThreshold": 250, "criticalThreshold": 1500, "maxSeverity": 2048, "numSamples": 2 }, { "timestamp": 1442018755880, "minValue": 1, "average": 1, "maxValue": 1, "warningThreshold": 250, "criticalThreshold": 1500, "maxSeverity": 2048, "numSamples": 2 }, { "timestamp": 1442019055880, "minValue": 1, "average": 1, "maxValue": 1, "warningThreshold": 250, "criticalThreshold": 1500, "maxSeverity": 2048, "numSamples": 1 }, { "timestamp": 1442019355880, "minValue": 1, "average": 1, "maxValue": 1, "warningThreshold": 250, "criticalThreshold": 1500, "maxSeverity": 2048, "numSamples": 2 }, { "timestamp": 1442019655880, "minValue": 1, "average": 1, "maxValue": 1, "warningThreshold": 250, "criticalThreshold": 1500, "maxSeverity": 2048, "numSamples": 2 }, { "timestamp": 1442019955880, "minValue": 1, "average": 1, "maxValue": 1, "warningThreshold": 250, "criticalThreshold": 1500, "maxSeverity": 2048, "numSamples": 1 }, { "timestamp": 1442020255880, "minValue": 1, "average": 1, "maxValue": 1, "warningThreshold": 250, "criticalThreshold": 1500, "maxSeverity": 2048, "numSamples": 2 }, { "timestamp": 1442020555880, "minValue": 1, "average": 1, "maxValue": 1, "warningThreshold": 250, "criticalThreshold": 1500, "maxSeverity": 2048, "numSamples": 2 }, { "timestamp": 1442020855880, "minValue": 1, "average": 1, "maxValue": 1, "warningThreshold": 250, "criticalThreshold": 1500, "maxSeverity": 2048, "numSamples": 1 }, { "timestamp": 1442021155880, "minValue": 1, "average": 1, "maxValue": 1, "warningThreshold": 250, "criticalThreshold": 1500, "maxSeverity": 2048, "numSamples": 1 } ] } ] }}</p> </article> </main>