Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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

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

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.

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Statuspage

New feature: Slack notifications for Statuspage

We're excited to announce the release of a long-requested feature on Statuspage. Now visitors to your status page can subscribe to get notified in Slack when you report an incident or maintenance. Th...

1,127 views 0 13
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you