public async Task <SuccessResponse> CreateAsync(string objectName, object record) { if (string.IsNullOrEmpty(objectName)) { throw new ArgumentNullException("objectName"); } if (record == null) { throw new ArgumentNullException("record"); } return(await _jsonHttpClient.HttpPostAsync <SuccessResponse>(record, string.Format("sobjects/{0}", objectName)).ConfigureAwait(false)); }
public Task <T> PostFeedItemAsync <T>(FeedItemInput feedItemInput, string userId) { // Feed items not available post v30.0 if (float.Parse(_jsonHttpClient.GetApiVersion().Substring(1)) > 30.0) { return(_jsonHttpClient.HttpPostAsync <T>(feedItemInput, "chatter/feed-elements")); } return(_jsonHttpClient.HttpPostAsync <T>(feedItemInput, string.Format("chatter/feeds/news/{0}/{1}", userId, _itemsOrElements))); }
public async Task Requests_CheckHttpRequestMessage_HttpPost() { var client = new HttpClient(new ServiceClientRouteHandler(r => { Assert.AreEqual(r.RequestUri.ToString(), "http://localhost:1899/services/data/v36/wade"); Assert.IsNotNull(r.Headers.UserAgent); Assert.AreEqual(r.Headers.UserAgent.ToString(), UserAgent + "/v36"); Assert.IsNotNull(r.Headers.Authorization); Assert.AreEqual(r.Headers.Authorization.ToString(), "Bearer accessToken"); })); using (var httpClient = new JsonHttpClient("http://localhost:1899", "v36", "accessToken", client)) { await httpClient.HttpPostAsync <object>(null, "wade"); } }
public async void Requests_CheckHttpRequestMessage_HttpPost() { var client = new HttpClient(new ServiceClientRouteHandler(r => { Assert.AreEqual(r.RequestUri.ToString(), "http://localhost:1899/services/data/v34/wade"); Assert.IsNotNull(r.Headers.UserAgent); Assert.AreEqual(r.Headers.UserAgent.ToString(), UserAgent + "/v34"); Assert.IsNotNull(r.Headers.Authorization); Assert.AreEqual(r.Headers.Authorization.ToString(), "Bearer accessToken"); })); using (var httpClient = new JsonHttpClient("http://localhost:1899", "v34", "accessToken", client)) { await httpClient.HttpPostAsync<object>(null, "wade"); } }