%% Create HTTP Request Message
% Format an HTTP message requesting a server to add text to a website. This example only formats the message and does not send the data.
% Add content to the message body.

data = 'Data to send';
body = matlab.net.http.MessageBody(data);
body.show

%
% Create a Content-Type header field describing the data type of the body.

contentTypeField = matlab.net.http.field.ContentTypeField('text/plain');

%
% Create an Accept header field specifying the data types acceptable in the response message.

type1 = matlab.net.http.MediaType('text/*');
type2 = matlab.net.http.MediaType('application/json','q','.5');
acceptField = matlab.net.http.field.AcceptField([type1 type2]);

%
% Create a request header containing the two header fields.

header = [acceptField contentTypeField];

%
% Specify that this message is a PUT request.

method = matlab.net.http.RequestMethod.PUT;

%
% Create the request message and display the contents.

request = matlab.net.http.RequestMessage(method,header,body);
show(request)

% Copyright 2012 The MathWorks, Inc.