public void AddParameter(string name, object value) { if (!string.IsNullOrEmpty(_body)) { throw new NotSupportedException("Cannot have a body and parameters"); } if (ParamsType == RequestParamsType.Body) { Headers["Content-Type"] = RestContentTypes.GetContentTypeHeader(RestContentTypes.FormUrlEncoded, Encoding); } Parameters[name] = value.ToString(); }
public void AddBody(string content, string contentType, Encoding encoding = null) { if (ParamsType != RequestParamsType.Body) { throw new NotSupportedException($"{Method} cannot have a body"); } else if (Parameters.Count > 0) { throw new NotSupportedException("Cannot have a body and parameters"); } if (encoding != null) { Encoding = encoding; } Headers["Content-Type"] = RestContentTypes.GetContentTypeHeader(contentType, Encoding); _body = content; }