How to pass API key in VBA for Get and Post Request?

后端 未结 2 1175
挽巷
挽巷 2021-01-16 23:39

I am using https://developer.companieshouse.gov.uk/api/docs/ to access an API I have my API key, however, i am not sure how to pass that from VBA. So far i tried below

2条回答
  •  一个人的身影
    2021-01-17 00:18

    I found it.. i was missing to encode the key

    Function EncodeBase64(text As String) As String
      Dim arrData() As Byte
      arrData = StrConv(text, vbFromUnicode)
    
      Dim objXML As MSXML2.DOMDocument
      Dim objNode As MSXML2.IXMLDOMElement
    
      Set objXML = New MSXML2.DOMDocument
      Set objNode = objXML.createElement("b64")
    
      objNode.DataType = "bin.base64"
      objNode.nodeTypedValue = arrData
      EncodeBase64 = objNode.text
    
      Set objNode = Nothing
      Set objXML = Nothing
    End Function
    

提交回复
热议问题