如何使用MATLAB的webwrite发布JSON参数(请求有效负载)?

我正在将数据采集模块与Web服务器一起使用。使用MATLAB,我要发布运行命令以开始采集。以下是我的错误响应命令。

  
    

s_sch ='http://webdaq316-ae.local/api/v1.0/schedule/status/';

         

options = weboptions('ContentType','json','MediaType','application / json','RequestMethod','post','ArrayFormat','json')

         

选项=     具有属性的weboptions:

  
  CharacterEncoding: 'auto'
          UserAgent: 'MATLAB 9.5.0.944444 (R2018b)'
            Timeout: 5
           username: ''
           Password: ''
            KeyName: ''
           KeyValue: ''
        ContentType: 'json'
      ContentReader: []
          MediaType: 'application/json'
      RequestMethod: 'post'
        ArrayFormat: 'json'
       HeaderFields: []
CertificateFilename: 'C:\Program Files\MATLAB\R2018b\sys\certificates\ca\rootcerts.pem'
  
    

apikey ='真实'

         

apikey =

'True'
         

json_command = ['{“ run”:',apikey,'}']

json_command =
'{"run": True}'

start_sch = webwrite(s_sch,json_command,options)
  

但是,出现以下错误。

  

>   使用readContentFromWebService时出错(第46行)   服务器响应对URL的请求,返回状态415,并显示消息“”   http://webdaq316-ae.local/api/v1.0/schedule/status/

     

>   Webwrite错误(第139行)       [varargout {1:nargout}] = readContentFromWebService(连接,选项);

如果我通过网络服务器开始采集,则可以看到POST(使用Google Chrome的Developer Tools选项),其中包含带有代码的“请求有效载荷”: {run:true}

我在我的'json_command'参数中包含了这些参数,但还是没有运气。那是正确的方法吗?

wangxd925 回答:如何使用MATLAB的webwrite发布JSON参数(请求有效负载)?

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3141811.html

大家都在问