diff --git a/RestSharp.Tests/NamespacedXmlTests.cs b/RestSharp.Tests/NamespacedXmlTests.cs index 83d4ac74e..3b57e9ad8 100644 --- a/RestSharp.Tests/NamespacedXmlTests.cs +++ b/RestSharp.Tests/NamespacedXmlTests.cs @@ -1,4 +1,4 @@ -#region Licensed +#region Licensed // Copyright 2010 John Sheehan // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/RestSharp.sln b/RestSharp.sln index 567a74d71..8b68fe3d9 100644 --- a/RestSharp.sln +++ b/RestSharp.sln @@ -1,4 +1,4 @@ - + Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 2013 VisualStudioVersion = 12.0.30723.0 diff --git a/RestSharp/IRestRequest.cs b/RestSharp/IRestRequest.cs index 27fbd7a7e..76da46169 100644 --- a/RestSharp/IRestRequest.cs +++ b/RestSharp/IRestRequest.cs @@ -160,7 +160,8 @@ public interface IRestRequest #endif /// - /// Serializes obj to format specified by RequestFormat, but passes xmlNamespace if using the default XmlSerializer + /// Serializes obj to format specified by RequestFormat, but passes xmlNamespace if using the default XmlSerializer. + /// The default format is XML. Change RequestFormat if you wish to use a different serialization format. /// /// The object to serialize /// The XML namespace to use when serializing @@ -169,11 +170,35 @@ public interface IRestRequest /// /// Serializes obj to data format specified by RequestFormat and adds it to the request body. + /// The default format is XML. Change RequestFormat if you wish to use a different serialization format. /// /// The object to serialize /// This request IRestRequest AddBody (object obj); + /// + /// Serializes obj to JSON format and adds it to the request body. + /// + /// The object to serialize + /// This request + IRestRequest AddJsonBody(object obj); + + /// + /// Serializes obj to XML format and adds it to the request body. + /// + /// The object to serialize + /// This request + IRestRequest AddXmlBody(object obj); + + /// + /// Serializes obj to format specified by RequestFormat, but passes xmlNamespace if using the default XmlSerializer + /// Serializes obj to XML format and passes xmlNamespace then adds it to the request body. + /// + /// The object to serialize + /// The XML namespace to use when serializing + /// This request + IRestRequest AddXmlBody(object obj, string xmlNamespace); + /// /// Calls AddParameter() for all public, readable properties specified in the includedProperties list /// diff --git a/RestSharp/RestRequest.cs b/RestSharp/RestRequest.cs index 4e7600a42..166475f7d 100644 --- a/RestSharp/RestRequest.cs +++ b/RestSharp/RestRequest.cs @@ -207,7 +207,8 @@ private IRestRequest AddFile (FileParameter file) } /// - /// Serializes obj to format specified by RequestFormat, but passes xmlNamespace if using the default XmlSerializer + /// Serializes obj to format specified by RequestFormat, but passes xmlNamespace if using the default XmlSerializer. + /// The default format is XML. Change RequestFormat if you wish to use a different serialization format. /// /// The object to serialize /// The XML namespace to use when serializing @@ -244,6 +245,7 @@ public IRestRequest AddBody (object obj, string xmlNamespace) /// /// Serializes obj to data format specified by RequestFormat and adds it to the request body. + /// The default format is XML. Change RequestFormat if you wish to use a different serialization format. /// /// The object to serialize /// This request @@ -252,6 +254,42 @@ public IRestRequest AddBody (object obj) return AddBody(obj, ""); } + /// + /// Serializes obj to JSON format and adds it to the request body. + /// + /// The object to serialize + /// This request + public IRestRequest AddJsonBody(object obj) + { + RequestFormat = DataFormat.Json; + return AddBody(obj, ""); + } + + /// + /// Serializes obj to XML format and adds it to the request body. + /// + /// The object to serialize + /// This request + public IRestRequest AddXmlBody(object obj) + { + RequestFormat = DataFormat.Xml; + return AddBody(obj, ""); + } + + /// + /// Serializes obj to format specified by RequestFormat, but passes xmlNamespace if using the default XmlSerializer + /// Serializes obj to XML format and passes xmlNamespace then adds it to the request body. + /// + /// The object to serialize + /// The XML namespace to use when serializing + /// This request + public IRestRequest AddXmlBody(object obj, string xmlNamespace) + { + RequestFormat = DataFormat.Xml; + return AddBody(obj, xmlNamespace); + } + + /// /// Calls AddParameter() for all public, readable properties specified in the includedProperties list ///