public async Task CreateCustomerAsync(RunMyAccountsContact r) { var request = new RestRequest("{tenant}/customers", Method.Post); request.RequestFormat = DataFormat.Json; // request.JsonSerializer = serializer; request.AddBody(r); try { var response = await client.ExecuteAsync(request); if (response.ErrorException != null) { throw new Exception("Failed to add RMA Contact: " + response.ErrorMessage); } if (response.Content.Contains("{ \"error\": \"")) { throw new Exception("Failed to add RMA Contact: " + response.Content); } } catch (Exception e) { throw new Exception("Adding failed with: " + e.StackTrace); } }
public void CreateCustomer(RunMyAccountsContact r) { var task = CreateCustomerAsync(r); task.Wait(); }