title: Passing API key and parameters using VBA in a POST request
body: <p>I have been trying to wrap my head around this VBA-Web doc <a href="http://vba-tools.github.io/VBA-Web/docs/" rel="nofollow noreferrer">http://vba-tools.github.io/VBA-Web/docs/</a> in order to pass auth_key and other parameters in a post request. I understand the concept of encoding the auth_key as explained here <a href="https://stackoverflow.com/questions/50185113/how-to-pass-api-key-in-vba-for-get-and-post-request">How to pass API key in VBA for Get and Post Request?</a>. But I need help to include all the parameters below in VBA. </p>
  
  <p>UPDATE:
  I was able to make QHarr's code below work. But I'm still finding it hard to use my own curl parameters below. I've tried using EncodeBase64(apikey) but I'm not there yet.</p>
  
  <pre><code>Public Sub GetResults()
      Dim data As String, json As Object '&lt;  VBE &gt; Tools &gt; References &gt; Microsoft Scripting Runtime
      data = "{""domainNames"":[""google.com""]}"
      With CreateObject("WinHttp.WinHttpRequest.5.1")
          .Open "POST", "https://api.dev.name.com/v4/domains:checkAvailability", False
          .setRequestHeader "User-Agent", "Mozilla/5.0"
          .setRequestHeader "Content-Type", "application/x-www-form-urlencoded; charset=UTF-8"
          .setRequestHeader "Authorization", "Basic " + _
              EncodeBase64("username" + ":" + "Token")
          .send data
          Set json = JsonConverter.ParseJson(.responseText)
          Dim result As Object
          For Each result In json("results")
              Debug.Print result("domainName")
          Next
      End With
  End Sub
  
  
  
  Function EncodeBase64(text As String) As String
  
  
    Dim arrData() As Byte
    arrData = StrConv(text, vbFromUnicode)
  
    Dim objXML As MSXML2.DOMDocument60
    Dim objNode As MSXML2.IXMLDOMElement
  
    Set objXML = New MSXML2.DOMDocument60
    Set objNode = objXML.createElement("b64")
  
    objNode.DataType = "bin.base64"
    objNode.nodeTypedValue = arrData
    EncodeBase64 = Application.Clean(objNode.text)
  
    Set objNode = Nothing
    Set objXML = Nothing
  End Function
  </code></pre>
  
  <p>Here is the API doc - <a href="https://cloud.ibm.com/apidocs/" rel="nofollow noreferrer">https://cloud.ibm.com/apidocs/</a></p>
  
  <p>Feature request:</p>
  
  <pre><code>curl -X POST \
  -H "Content-Type: application/json" \
  -u "apikey:{apikey}" \
  -d @parameters.json \
  "{url}/v1/analyze?version=2019-07-12"
  </code></pre>
  
  <p>Example parameter:</p>
  
  <pre><code>{
    "features": {
      "semantic_roles": {}
    },
    "text": "IBM has one of the largest workforces in the world"
  }
  </code></pre>