private static BizwebRequestMessage CreateRequestMessage(BizwebAuthorizationState authState, string path, HttpMethod method, string rootElement = null, object payload = null) { JsonContent content = null; if (payload == null) { return(RequestEngine.CreateRequest(authState, path, method, rootElement: rootElement)); } if (method != HttpMethod.Get && method != HttpMethod.Delete) { content = new JsonContent(payload); } else if (payload is Parameterizable) { path = RequestEngine.CreateUriPathAndQuery(path, ((Parameterizable)payload).ToParameters()); } else { //foreach (var propertyInfo in payload.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance)) //{ // req.AddParameter(propertyInfo.Name, propertyInfo.GetValue(payload)); //} var token = JToken.FromObject(payload); var queryParams = token.Select(s => { var i = (JProperty)s; return(new KeyValuePair <string, object>(i.Name, i.Value)); }); path = RequestEngine.CreateUriPathAndQuery(path, queryParams); } return(RequestEngine.CreateRequest(authState, path, method, content, rootElement)); }