【问题标题】:How to access Azure Table Storage API using Node-Red HTTP Request node如何使用 Node-Red HTTP 请求节点访问 Azure 表存储 API
【发布时间】:2019-09-23 14:12:01
【问题描述】:

我正在尝试从 Node-Red 访问消息/数据并将其存储到现有的 Azure 表存储表中。我正在使用为 Azure 存储帐户配置的指定 SAS 令牌。我可以在 PostMan 中运行 GET 请求而不会出现任何问题,但是当在 Node-Red 中尝试完全相同的东西/查询字符串 URL 时,它会在使用的 Atom 格式上创建一条错误消息。

我使用带有 SAS-token 的 URL(比如这个)来访问 Postman 中的表数据:

https://iotcdatastorage.table.core.windows.net/Table1?sv=2018-03-28&ss=t&srt=sco&sp=rwdlacu&se=2019-09-23T20:04:34Z&st=2019-09-23T12:04:34Z&spr=https&sig=a3LSLWu0yVUqzLVaI3S9yL6ZO3acFf8XIBTCHUhglD8%3E. 

在 Postman 返回 200 OK 响应代码时,一切正常。

在 Node-Red HTTP 请求节点中使用相同的确切 URL 时,会产生如下错误:

<error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"><code>AtomFormatNotSupported</code><message xml:lang="en-US">Atom format is not supported.RequestId:149acccd-b002-0041-6b18-72159a000000Time:2019-09-23T14:09:38.7798256Z</message></error> 

这种 Atom 格式是什么?为什么请求在 Postman 而不是 Node-Red 中有效?我可以通过格式或相关标题来解决这个问题吗?

【问题讨论】:

    标签: azure-table-storage node-red


    【解决方案1】:

    花了一些时间,但在我阅读后我想通了。

    我附上了 Node-Red 的工作流程供您参考:

    [{"id":"f87e7bab.1b7b68","type":"inject","z":"96dd1da4.97f65","name":"","topic":"","payload" :"","payloadType":"date","re​​peat":"","crontab":"","once":false,"onceDelay":0.1,"x":220,"y":120, "wires":[["b301afc2.5e844"]]},{"id":"1a565e01.dc29b2","type":"debug","z":"96dd1da4.97f65","name":"检索表条目","active":true,"tosidebar":true,"console":true,"tostatus":false,"complete":"payload.value","x":810,"y":120, "wires":[]},{"id":"b301afc2.5e844","type":"change","z":"96dd1da4.97f65","name":"Set Headers","rules": [{"t":"set","p":"headers","pt":"msg","to":"{}","tot":"json"},{"t":" set","p":"headers.content-type","pt":"msg","to":"application/json","tot":"str"},{"t":"set" ,"p":"headers.accept","pt":"msg","to":"application/json;odata=nometadata","tot":"str"}],"action":"", "property":"","from":"","to":"","re​​g":false,"x":410,"y":120,"wires":[["764f1dd1.c44564" ]]},{"id":"764f1dd1.c44564","type":"www-request","z":"96dd1da4.97f65","name":"","method":"GET", "ret":"obj","url":"https://iotcdatastorage.table.core.windows.net/Table1?sv=2018-03-28&ss=t&srt=sco&sp=rwdlacu&se=2019-09-26T13:35:37Z&st=2019-09-24T05:35:37Z&spr=https&sig=7ogTJRILvYLKce%2B5aiePdBJ%2BXys4pc5%2FH8DmbgBvovk%3Z","follow-re指导":true,"persistent-http":true,"tls":"","x":590,"y":120,"wires":[["1a565e01.dc29b2"]]},{"id ":"f62f1d4e.52b8a","type":"comment","z":"96dd1da4.97f65","name":"检索添加到 Azure 表存储表","info":"","x ":330,"y":60,"wires":[]},{"id":"cd48e5e9.beeac8","type":"inject","z":"96dd1da4.97f65","name" :"","topic":"","payload":"","payloadType":"date","re​​peat":"","crontab":"","once":false,"onceDelay": 0.1,"x":220,"y":160,"wires":[["31d9e715.0cb738"]]},{"id":"ad13b55b.042e78","type":"change","z ":"96dd1da4.97f65","name":"设置标题","rules":[{"t":"set","p":"headers","pt":"msg","to" :"{}","tot":"json"},{"t":"set","p":"headers.content-type","pt":"msg","to":"应用程序/json","tot":"str"},{"t":"set","p":"headers.accept","pt":"msg","to":"application/json;odata =nometadata","tot":"str"}],"action":"","property":"","from":"","to":"","re​​g":false,"x ":590,"y":160,"wires":[["81917f33.acfa5"]]},{"id":"81917f33.acfa5","type":"www-request","z": "96dd1da4.97f65","name":"","method":"POST","re​​t ":"obj","url":"https://iotcdatastorage.table.core.windows.net/Table1?sv=2018-03-28&ss=t&srt=sco&sp=rwdlacu&se=2019-09-26T13:35:37Z&st=2019-09-24T05:35:37Z&spr=https&sig=7ogTJRILvYLKce%2B5aiePdBJ%2BXys4pc5%2FH8DmbgBvovk%3Z","follow-redirects":true,"persistent-http":true,"tls":"","x":770,"y":160 ,"wires":[["29f660c6.3c1b"]]},{"id":"29f660c6.3c1b","type":"debug","z":"96dd1da4.97f65","name":"添加表条目","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":960,"y":160," wires":[]},{"id":"31d9e715.0cb738","type":"function","z":"96dd1da4.97f65","name":"Add RowKey","func":" var today = new Date();\ndatesent = today.toISOString();\n\nmsg.payload =\n{\n \"PartitionKey\": partitionKeyString,\n \"RowKey\": datesent,\n \ "vibration\": 值,\n \"running\": 是/否\n}\n\nreturn msg;","outputs":1,"noerr":0,"x":410,"y" :160,"电线":[["ad13b55b.042e78"]]}]

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-03-28
      • 1970-01-01
      相关资源
      最近更新 更多