Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If you have a .NET client to perform the POST then use the below method to POST your request body to a RESTful service:</p> <pre><code>private static byte[] ToByteArrayUsingJsonContractSer&lt;T&gt; (T requestBody) { byte[] bytes = null; var serializer1 = new DataContractJsonSerializer(typeof(T)); var ms1 = new MemoryStream(); serializer1.WriteObject(ms1, requestBody); ms1.Position = 0; var reader = new StreamReader(ms1); bytes = ms1.ToArray(); return bytes; } </code></pre> <p>Once you have the bytes of request body then just post it to the stream of the request and monitor it using Fiddler and you should see your JSON request. Make sure to set your Content-Type to <code>application/json</code></p> <p>Please find a sample request that i have used using the above method with start date as DateTime.Now and booking end date as DateTime.Now.AddDays(1)</p> <pre><code>POST http://localhost/SampleService/Service1.svc/postmethod/new HTTP/1.1 Content-Type: application/json Host: rajeshwin7 Content-Length: 144 Expect: 100-continue Connection: Keep-Alive {"BookingEnd":"\/Date(1332842057631+0100)\/","BookingID":1,"BookingName":"client sent","BookingStart":"\/Date(1332755657631+0100)\/","RoomID":2} </code></pre> <p>And once i do the above i get back response as shown below:</p> <pre><code>HTTP/1.1 200 OK Cache-Control: private Content-Length: 334 Content-Type: application/xml; charset=utf-8 Server: Microsoft-IIS/7.5 X-AspNet-Version: 4.0.30319 Set-Cookie: ASP.NET_SessionId=XXXXXXXXXXXXXXXXXXXXXX; path=/; HttpOnly X-Powered-By: ASP.NET Date: Mon, 26 Mar 2012 09:54:53 GMT &lt;Booking xmlns="http://schemas.datacontract.org/2004/07/XMLService" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"&gt;&lt;BookingEnd&gt;2012-03-27T10:54:17.631+01:00&lt;/BookingEnd&gt;&lt;BookingID&gt;1&lt;/BookingID&gt;&lt;BookingName&gt;client sent from server&lt;/BookingName&gt;&lt;BookingStart&gt;2012-03-26T10:54:17.631+01:00&lt;/BookingStart&gt;&lt;RoomID&gt;2&lt;/RoomID&gt;&lt;/Booking&gt; </code></pre> <p>Notice the bookingName element that has a string appended from server (which i have used for testing purpose)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload