Hello Fluksonians,
My name is Roan and I'm a newcommer to the community.
We are using a Fluksometer for our school project and don't have it employed yet.
However, we do want to start developing our mobile wepapplication.
Using the information of this post: https://www.flukso.net/content/jsonrest-api-released (it seems a bit outdated to me) we are trying to create a working AJAX example.
This is our code:
// Create request
var xhr = new XMLHttpRequest();
var interval = 'interval=hour';
var unit = '&unit=watt'
var url = 'https://api.flukso.net/sensor/c1411c6b4f9910bbbab09f145f8533b9?' + interval + unit;
xhr.open('GET',url,true);
//Set headers
xhr.setRequestHeader('Accept','application/json');
xhr.setRequestHeader('X-Version','1.0');
xhr.setRequestHeader('X-Token','d8a8ab8893ea73f768b66b45234b5c3a');
//Send request
xhr.send();
The error I am recieving in my console is: "NetworkError: 405 Method Not Allowed - https://api.flukso.net/sensor/c1411c6b4f9910bbbab09f145f8533b9?interval=hour&unit=watt"
Also the URL visited at https://api.flukso.net/sensor/c1411c6b4f9910bbbab09f145f8533b9?interval=... is perfectly blank. Shouldn't I get data? I Googled the error and it says 'Method not allowed' is only ever seen when using a POST where POST is not alllowed.
The token and sensor id are directly copied from the 'working' example. The headers seem okay too. Is the working example still valid? Is there any other test server I can connect to trough the API? To be clear again: I do not currently have acces to a own Fluksometer yet, so There is no way for me to get my own sensor id or token.
Is there anybody that can help me further setting up my AJAX example on a Flukso test server?
Have a great day,
Roan.