【发布时间】:2019-09-21 15:02:09
【问题描述】:
我想从 Matlab 将数据保存到 firebase。 firebase 是否有类似 ThingSpeak 之类的 api 调用?如何通过 API 调用从 matlab 发送 JSON 数据?
我正在从 Matlab 进行 API 调用,例如 JSON:
Firebase_Url = 'https://ecgproject-86945.firebaseio.com/';
writeApiKey = '***';
data = ['api_key=',writeApiKey,'&name=',"JSOpn9ZC54A4P4RoqVa"];
response = webwrite(Firebase_Url,data)
%data = struct('api_key',writeApiKey,'field1',data); //also tries this
%options = weboptions('MediaType','application/json');
错误:
Error using readContentFromWebService (line 46)
The server returned the status 405 with message "Method Not Allowed" in response to the
request to URL https://ecgproject-86945.firebaseio.com/.
Error in webwrite (line 139)
[varargout{1:nargout}] = readContentFromWebService(connection, options);
Error in Untitled (line 16)
response = webwrite(Firebase_Url,data)
【问题讨论】:
-
我昨天回答了一个非常相似的问题:stackoverflow.com/questions/53467712/…
-
是,但没有指定如何使用 Matlab 中的 Rest 服务。
-
我对“从 Matlab 执行 HTTP 调用”进行了快速搜索,看到了很多有希望的结果。你有没有尝试过这些?你在哪里卡住了?
-
我以前用过 Thingspeak。我按照 matlab 的 webwrite() 的教程进行操作。但我猜firebase对数据有不同的格式。这是链接:mathworks.com/help/matlab/ref/webwrite.html。我还用我现在在 matlab 上为 firebase 运行的代码更新了我的问题。
-
如果您尝试过某事,请编辑您的问题以包含您尝试过的内容(您刚刚看到的内容)。从错误消息看来,您没有传递请求正文,这是执行 HTTP POST 请求时所必需的。您是否尝试过 mathworks.com/help/matlab/ref/webwrite.html 中的“写入 JSON 对象”示例?