The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

My api key is when i gen it it does not show the api key

Shawn Hamby
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
June 18, 2020

also when i put this code in i get a error 

 

CODE: 

  1. var http = require('http');

  2.  

  3. // The following 4 are the actual values that pertain to your account and this specific metric.

  4. var apiKey = 'your-api-key-goes-here';

  5. var pageId = 'ktnkzq1wp4wc';

  6. var metricId = 'ly0m7lhl7gj0';

  7. var apiBase = 'https://api.statuspage.io/v1';

  8.  

  9. var url = apiBase + '/pages/' + pageId + '/metrics/' + metricId + '/data.json';

  10. var authHeader = { 'Authorization': 'OAuth ' + apiKey };

  11. var options = { method: 'POST', headers: authHeader };

  12.  

  13. // Need at least 1 data point for every 5 minutes.

  14. // Submit random data for the whole day.

  15. var totalPoints = 60 / 5 * 24;

  16. var epochInSeconds = Math.floor(new Date() / 1000);

  17.  

  18. // This function gets called every second.

  19. function submit(count) {

  20. count = count + 1;

  21.  

  22. if(count > totalPoints) return;

  23.  

  24. var currentTimestamp = epochInSeconds - (count - 1) * 5 * 60;

  25. var randomValue = Math.floor(Math.random() * 1000);

  26.  

  27. var data = {

  28. timestamp: currentTimestamp,

  29. value: randomValue,

  30. };

  31.  

  32. var request = http.request(url, options, function (res) {

  33. res.on('data', function () {

  34. console.log('Submitted point ' + count + ' of ' + totalPoints);

  35. });

  36. res.on('end', function() {

  37. setTimeout(function() { submit(count); }, 1000);

  38. });

  39. });

  40.  

  41. request.end(JSON.stringify({ data: data }));

  42. }

  43.  

  44. // Initial call to start submitting data.

  45. submit(0);

 

 

ERROR: 

working
working
_http_client.js:152
throw new ERR_INVALID_PROTOCOL(protocol, expectedProtocol);
^

TypeError [ERR_INVALID_PROTOCOL]: Protocol "https:" not supported. Expected "http:"
at new ClientRequest (_http_client.js:152:11)
at Object.request (http.js:46:10)
at submit (C:\Users\ShawnHamby\Desktop\John\APi.js:33:22)
at Object.<anonymous> (C:\Users\ShawnHamby\Desktop\John\APi.js:47:1)
at Module._compile (internal/modules/cjs/loader.js:1138:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
at Module.load (internal/modules/cjs/loader.js:986:32)
at Function.Module._load (internal/modules/cjs/loader.js:879:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
at internal/main/run_main_module.js:17:47 {
code: 'ERR_INVALID_PROTOCOL'
}

1 answer

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

0 votes
Nick Coates
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
June 19, 2020

Hi Shawn,

I think this is a Node (this looks like NodeJS, correct if I'm wrong) error where it's using the https protocol in the apiBase parameter and is expecting http instead.

TypeError [ERR_INVALID_PROTOCOL]: Protocol "https:" not supported. Expected "http:"

Thanks,
Nick Coates
Product Owner - Service Status, Broadcom.

TAGS
AUG Leaders

Atlassian Community Events