title: Matlab: using webwrite to send image through a simple REST API
body: <p>I was trying to do image classification through a web at service at  and
  I had no problem to use curl to retrieve token: </p>
  
  <pre><code>curl -i -X POST -H "Authorization:MY Key" -F "image_request[image]=@/path/to/myimage" -F "image_request[locale]=en-US" https://api.cloudsightapi.com/image_requests
  </code></pre>
  
  <p>However, it is not successful when I tried webwrite, it returned "HTTP 400" error. </p>
  
  <pre><code>option=weboptions('KeyName','Authorization','KeyValue','mykey')
  fid = fopen('/path/to/myimage');
  img = fread(fid,Inf,'*uint8');
  fclose(fid);
  response=webwrite('https://api.cloudsightapi.com/image_requests',...
    'image_request[image]',img,...
    'image_request[locale]','en-US',option); 
  </code></pre>
  
  <p>I guess it because the function webwrite in this format doesn't support "multipart/form-data" and I need change the media type. Then I tried to send data as an JSON object</p>
  
  <pre><code>option=weboptions('KeyName','Authorization','KeyValue','mykey','MediaType','application/json')
  data=struct('image_request[image]',im,'image_request[locale]','en-US');
  response=webwrite('https://api.cloudsightapi.com/image_requests',data,option)
  </code></pre>
  
  <p>But the field name in Matlab struct does not allow "[". 
  Any suggestion? </p>