/// <summary> /// Sets the request body from an object. Serialized as JSON /// </summary> /// <param name="settings">The settings.</param> /// <param name="data">The object to set as the request body. It will be serialized to JSON.</param> /// <param name="indentOutput">Option to indent the output of the format</param> /// <remarks> /// This uses the JavascriptSerializer /// </remarks> /// <returns>The same <see cref="HttpSettings"/> instance so that multiple calls can be chained.</returns> public static HttpSettings SetJsonRequestBody <T>(this HttpSettings settings, T data, bool indentOutput = true) { if (settings == null) { throw new ArgumentNullException(nameof(settings)); } if (data == null) { throw new ArgumentNullException(nameof(data)); } var requestBody = JsonEncoder.SerializeObject(data); settings.RequestBody = Encoding.UTF8.GetBytes(requestBody); settings.SetContentType("application/json"); return(settings); }