public async Task CreateInvoiceAsync(RunMyAccountsInvoice i) { Regex rgx = new Regex("[^a-zA-Z0-9_\\.\\-\\\\]"); i.ordnumber = rgx.Replace(i.ordnumber, ""); var request = new RestRequest("{tenant}/invoices", Method.Post); request.RequestFormat = DataFormat.Json; // request.JsonSerializer = serializer; request.AddBody(i); var response = await client.ExecuteAsync(request); if (response.ErrorException != null) { throw new Exception("Failed to add RMA Invoice: " + response.ErrorMessage); } if (response.Content.Contains("{ \"error\": \"")) { throw new Exception("Failed to add RMA Invoice: " + response.Content); } }
public void CreateInvoice(RunMyAccountsInvoice i) { var task = CreateInvoiceAsync(i); task.Wait(); }