title: call a https REST service from VBA
body: <p>I try to get data form this rest service. I a browser it works fine. Now I try to do this in VBA to display the data in Excel</p>
  
  <p><a href="https://energidataservice.dk/api/action/datastore_search?resource_id=ec797392-7ba5-4c3a-b021-8ae302ac295a&amp;limit=5" rel="nofollow noreferrer">https://energidataservice.dk/api/action/datastore_search?resource_id=ec797392-7ba5-4c3a-b021-8ae302ac295a&amp;limit=5</a></p>
  
  <p>I believe it has to do with https and TSL. When I code this in C# and add this line it works. I just don't know how to do this in VBA</p>
  
  <pre><code>'ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 - object required
  
  Dim reader As New WinHttpRequest
  Dim json As New JSONParser
  Dim ws As Worksheet: Set ws = ActiveSheet
  
  Dim url As String
  url = ws.[EDS_URL]
  
  ' reader.Option(9) = 2720 - invalid procedure call
  reader.Open "GET", url, False
  
  reader.Send ' automation error
  </code></pre>
  
  <p>Without the TSL part I get automation error in the last line</p>