Thank you, @Jared-Wiltshire. That's excellent, I shall give that a go.
Posts made by gary
-
RE: Using my own AngularJS Directives in Custom Dashboards
-
Using my own AngularJS Directives in Custom Dashboards
Hi,
I have previous experience using AngularJS and would like some of my work to be reused. How can I register an AngularJS directive for use in a custom dashboard?
Regards,
Gary
-
RE: CRUD for data sources
@hrivers In my experience with the Mango API, sometimes you need to include the header 'x-xsrf-token' as well as the cookies.
Try this modification:
$headers = array( 'Accept: application/json', 'Content-Type: application/json', //multipart/form-data 'Connection: keep-alive', 'Cache-Control: no-cache', 'Cookie: XSRF-TOKEN='.$xsrf_token.';MANGO8080='.$mango8080, 'x-xsrf-token: ' . $xsrf_token //ADDED );
Gary
-
RE: How to storing selected datapoint value across the pages of the mango dashboards.
It sounds like this is not really a Mango related question but a web development related one.
You probably want to use localStorage. Alternatively you could use cookies but I think you're most likely to want to use localStorage. Cookies are sent to the server with every HTTP request, which would be pointless in the case of a Mango dashboard.
These APIs allow you to store data on the client machine for use at a later time. They have limitations and risks. The user can remove this data and it can expire when the user closes their browser or after a predefined period of time. You shouldn't store anything sensitive on the client side and when retrieving data, it should be treated with the same caution as any other input because it is easy for a malicious user to manipulate.
Gary
-
RE: How do I create event detectors using the Mango API?
Ok, thanks Joel. That's great to know. It sounds like v3 will be a big advance forward for Mango.
-
How do I create event detectors using the Mango API?
Hi,
I am creating a system that allows the dynamic addition of monitored devices. Through the Mango API I have successfully created data sources and data points. Some of the points created should have event detectors. All event detectors are state detectors in my system.
There doesn't seem to be any end points listed in the Swagger documentation for creating event detectors. So, how do I create event detectors using the Mango API?
Regards,
Gary
-
RE: How do I create a datasource using the Mango API?
@phildunlap Thank you. I will give it a try.
-
How do I create a datasource using the Mango API?
Hi,
Swagger shows some details of two API end points that potentially could be used. I'm not sure if I need to PUT to /rest/v1/data-sources/{XID} or POST to /rest/v1/data-sources . I have spent most time trying the PUT option as it is conceptually more appropriate but I get the same result either way.
My attempts have been met with 500 Server Error because I have not uploaded a correctly specified JSON object. I need an explanation of the JSON schema to upload. I tried to create a copy of an existing datasource by uploading the exported JSON for the original with a modified parameter values. The format is not the same as the Swagger documentation specifies so I wasn't surprised I didn't get it to work.
The swagger documentation doesn't make it obvious how to specify that it is a HTTP listener that I wish to create. There are parameters specific to this type that I want to set including IP white list and device ID white list.
Can anyone fill in the gaps please?
Thanks,
Gary
-
RE: How to access Rest API Login Endpoint using VBA
Hi,
To add to what phildunlap said, you must include 'application/json' in the accepts header.
If basing your code on the question and answers on that stackoverflow page, you would need to add the following line before invoking the send method:
objHTTP.setRequestHeader "accept", "application/json"
Regards,
Gary
-
RE: Log out inactive users?
@phildunlap Very useful information. I searched and found exactly what I needed to know in this answer. Thanks.
-
Problem using Websockets with Safari and solution
I have spent an embarrassingly long time tearing my hair out due to a problem that happens with the Safari browser both on MacOS and iOS. This problem does not affect Chrome, Firefox or IE. I hope this post helps someone else.
Our use case is a bespoke web based front end using the Mango API. We will use the Mango web interface for administration and expect our users to use the bespoke front end only.
If hosting a web site on a different domain to Mango, Safari users will have to change their settings or any attempt to use the realtime Mango API will result in 'NOT LOGGED IN' error messages. This is caused because Safaris default configuration will prevent it from sending the authentication cookie when initiating the web socket connection.
The setting in question is 'Cookies and website data'. It must be set to 'always allow'.
Using the same domain but different ports (enough to require CORS headers be configured for AJAX requests) will NOT cause this problem.
I believe that anyone trying to keep web server and Mango as separate concerns will have to experiment with subdomains.
Gary Ott
DVR Ltd -
RE: Mango 2.6 New Features
Hi Joel,
I am looking forward to getting my hands on it. Keep up the great work.
Is there an estimated release date yet?
Regards,
Gary Ott
DVR Ltd -
RE: Configuration of HTTP headers
Terry,
I have replicated the 401 error and found the cause. When this error occured, the response headers contain the field 'errors' with a value 'User not logged in'. After a little bit of experimenting, I have worked out what I did to cause this.
To replicate:
Using Chrome*, open the Mango web interface and log in.
Open in another tab of the same window, a web application that utilised the Mango API and log in.
Separate the two tabs into different browser windows.
Log out from the web application and you will receive the 401 error.*I haven't tried other browsers.
Explanation:
The two tabs utilise the same session cookie. The cookie must be associated with one of the two browser windows when the separation occurs. The domain of this cookie matches the domain in the address bar of the mango web interface so the browser understandably associates that cookie with the Mango web interface, not the web application. Now the web application does not have a log-in cookie.
Possible answers:
- Don't do that.
- Have the Mango API deliver a different cookie.
- Set an expiry time on the cookie.
For me #2 is preferable but that may not play well with custom dashboards.
Gary
-
RE: Configuration of HTTP headers
Unfortunately I am unable to reproduce the problem. I have not modified my code since Friday when I had this issue.
I have attached a section from ma.log timed just before I posted about the 401 error. I can't see anywhere within this that tells me the HTTP status code returned so I hope it is relevant.
I came across the 401 when clicking the 'log out' button in my application did nothing. I opened the developer tools in Chrome and immediately saw the error in the console. At the time, I was able to reproduce the error by refreshing the page, logging in and attempting to log out.
My application uses POST to /rest/v1/login/ and /rest/v1/logout/. The implementation details mirror MangoApi.js which I have been using as a reference implementation.
Attachment: download link
-
RE: Configuration of HTTP headers
Spoke a little too soon. logout is generating a 401 Unauthorised error. I can live with that for now!
-
RE: Configuration of HTTP headers
Terry,
Thank you very much.
Everything is now working as I had hoped.
Your help is greatly appreciated.
Gary
-
RE: Web sockets
Thank you for the custom module. I have seen you have added XID to the paylod object exactly as I asked. Much appreciated.
Gary
-
RE: Configuration of HTTP headers
Thanks Terry.
The four headers seem sufficient but I think free text control would be a more appropriate long term solution. I would like free text control of headers to be a low priority entry on your to-do list.
I tried to test what you have done but unfortunately I encountered the problem you said I would with the REST API. As log on is a prerequisite to other endpoints, I am having to revert to the the previous version.
Gary