end0tknr's kipple - 新web写経開発

http://d.hatena.ne.jp/end0tknr/ から移転しました

再・MSXML2.XMLHTTPでvbaからweb apiを利用 (POST版)

https://end0tknr.hateblo.jp/entry/20081115/1226755041

↑こちらの古いエントリーの続き、今回はPOST版

Function CallApiCalc(Model)
    Set http = CreateObject("MSXML2.XMLHTTP")
    http.Open "POST", "https://house.app.lowenergy.jp/api/v1/eval", False
    http.setRequestHeader "Accept", "application/xml"
    http.setRequestHeader "Content-Type", "text/xml"
    http.send CVar("<request><model>" & Model & "</model><format>NewStandard</format></request>")
    
    MsgBox http.Status
    MsgBox http.StatusText
    
    
    With Sheet16
        .Range("G13") = http.ResponseXML.SelectSingleNode("/response/E_H").Text
        .Range("G14") = http.ResponseXML.SelectSingleNode("/response/E_C").Text
        .Range("G15") = http.ResponseXML.SelectSingleNode("/response/E_V").Text
        .Range("G16") = http.ResponseXML.SelectSingleNode("/response/E_W").Text
        .Range("G17") = http.ResponseXML.SelectSingleNode("/response/E_L").Text
        .Range("G18") = http.ResponseXML.SelectSingleNode("/response/E_M").Text
        .Range("G19") = http.ResponseXML.SelectSingleNode("/response/E_S").Text
        .Range("G20") = http.ResponseXML.SelectSingleNode("/response/E_T").Text
        .Range("G26") = http.ResponseXML.SelectSingleNode("/response/E_PV_gen").Text
        .Range("H13") = http.ResponseXML.SelectSingleNode("/response/E_SH").Text
        .Range("H14") = http.ResponseXML.SelectSingleNode("/response/E_SC").Text
        .Range("H15") = http.ResponseXML.SelectSingleNode("/response/E_SV").Text
        .Range("H16") = http.ResponseXML.SelectSingleNode("/response/E_SW").Text
        .Range("H17") = http.ResponseXML.SelectSingleNode("/response/E_SL").Text
        .Range("H18") = http.ResponseXML.SelectSingleNode("/response/E_SM").Text
        .Range("H20") = http.ResponseXML.SelectSingleNode("/response/E_ST").Text
    End With
    
    Set http = Nothing
    
End Function