title: Matlab RESTful PUT Command - net.http - nesting body values
body: <p>I am using Matlab's matlab.net.http library to launch get, put and post commands to a website. I can successfully launch get and post commands.</p>
  
  <p>For example:
      <code>MyBody = matlab.net.http.MessageBody(struct('Id',YYYYYY,'WindfarmId',XXX,'Month','YYYY-MM-DD'));
      Request = matlab.net.http.RequestMessage;
      Request.Method = 'POST';
      Request.Header = matlab.net.http.HeaderField('Content-Type','application/json','Authorization',['Basic ' matlab.net.base64encode([Username ':' Password])]);
      Request.Body = MyBody;
      uri = matlab.net.URI(ENTERURLHERE);
      Response = Request.send(uri,MyHTTPOptions);
  </code>
  This works well. However using a PUT command I have to enter the equiavlent of this body (written in curl syntax):</p>
  
  <pre><code>-d '{ "InputValues": [ {"MetricLevelAId": 1, "MetricLevelBId": 1, "InputMetricId": 7, "Value": 56 } ] }'
  </code></pre>
  
  <p>I tried this:</p>
  
  <pre><code>data_InputValues = struct ('MetricLevelAId',1,'MetricLevelBId',1,'InputMetricId',7,'Value',56);
  MyBody = matlab.net.http.MessageBody(struct('InputValues',dataInputValues));
  </code></pre>
  
  <p>However I keep receiving the following 'Bad Request' response from the server:
  "Input values required"</p>
  
  <p>I think this is linked to the way Matlab interprets the body part of the request and passes it to the server, i.e. it cannot pass the nested struct correctly. Anyone got any ideas how to solve this?</p>
  
  <p>N.B. potentially linked to <a href="https://stackoverflow.com/questions/50329452/translating-curl-into-matlab-webwrite">Translating curl into Matlab/Webwrite</a> (it is dealing with a nested value)</p>