public void Test() { var mockRequest = new Request() { Records = new List <object>() }; mockRequest.Records.Add( new Dictionary <object, object> { { "attributes", new Dictionary <string, string> { { "type", "Account" }, { "referenceId", "06ss76046d243" } } }, { "Name", "coisa" }, { "Documento__c", "065476046d243" } } ); var mockBulkRequest = new BulkCreateRequest() { Request = mockRequest }; var context = JsonConvert.SerializeObject(mockBulkRequest.Request); }
public async Task <string> BulkCreatetAsync(BulkCreateRequest bulkRequest) { var context = JsonConvert.SerializeObject(bulkRequest.Request); httpClient = _baseAuthorization.GetHttpCliente(); var url = $"{ApiUrl}services/data/v{ApiCofiguration.Version}/composite/tree/{bulkRequest.Object}"; var request = new HttpRequestMessage(new HttpMethod("POST"), url) { Content = new StringContent(context, Encoding.UTF8, "application/json") }; var result = await _baseAuthorization.GetHttpCliente().SendAsync(request); var resultContent = await result.Content.ReadAsStringAsync(); if (!result.IsSuccessStatusCode) { throw new Exception($"Error=>> {resultContent} Token Expired In: {ComvertToDateTimeUnixTimestamp(_baseAuthorization.Timeout)}"); } result.EnsureSuccessStatusCode(); return(resultContent); }