0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

PythonとExcel VBAでのWeb API比較(T&D おんどとり Web Storage)

Posted at

PythonとExcel VBAの両方で、同じWeb APIを呼び出してコードの違いを確認した。

なお、Web APIはT&Dのおんどとり Web Storageを使用した。おんどとり Web Storageの利用にはT&Dの製品購入が前提となる。

おんどとり WebStorage API

WEB API仕様は次の通り。

今回はその中から現在値の取得と指定期間・件数によるデータの取得を試した。

リクエストヘッダ

header = {'Host':'api.webstrage.js:443','Content-Type': 'application/json','X-HTTP-Method-Override':'GET'}
Dim httpReq As New XMLHTTP60   '「Microsoft XML, v6.0」を参照設定
httpReq.Open "POST", "https://api.webstorage.jp/v1/devices/current"
httpReq.setRequestHeader "Host", "api.webstrage.js:443"
httpReq.setRequestHeader "Content-Type", "application/json"
httpReq.setRequestHeader "X-HTTP-Method-Override", "GET"

リクエストボディ

paylord = {'api-key':api_key,"login-id":login_id,'login-pass':password}
Dim sRequestBody As String
sRequestBody = "{"
sRequestBody = sRequestBody + """api-key"":""" & apikey & """"
sRequestBody = sRequestBody + ",""login-id"":""" & loginid & """"
sRequestBody = sRequestBody + ",""login-pass"":""" & loginpass & """"
sRequestBody = sRequestBody + "}"
    
httpReq.send sRequestBody

レスポンス

Excel VBAではレスポンスのJSONをそのまま解釈できなため、VBA-JSONを利用した。

ソース

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?