Discussions

Ask a Question
Back to all

Invoice Creation Failed

(edited)

Hi,

I am trying to test the interface by creating an invoice an pulling all the invoices; but I only get one invoice (id:254435) all the times. How can confirm. Questions:

  1. how can I confirm the invoice creation?
  2. and how to pull all the invoices.

Below is the code examples I am using:



var options = new RestClientOptions("https://api-staging.b2brouter.net/accounts/account/invoices");
var client = new RestClient(options);

var request = new RestRequest("", Method.Post);
request.AddHeader("accept", "application/json");
request.AddHeader("X-B2B-API-Version", "2025-10-13");
request.AddHeader("X-B2B-API-Key", "93*******92b");

// Correct JSON body
var body = new
{
send_after_import = false,
ack = false,
invoice = new
{
type = "IssuedInvoice",
bank_account = new { type = "iban" },
terms = "custom",
invoice_lines_attributes = new[]
{
new
{
unit = 1,
quantity = 1,
price = 1000,
description = "Professional services",
taxes_attributes = new[]
{
new
{
name = "VAT",
category = "S",
percent = 21,
comment = "VAT 21%"
}
}
}
},
apply_taxes_to_charge = false,
charge_is_reimbursable_expense = false,
number = "0002",
contact_id = "ESA47002878",
date = "2025-11-20",
due_date = "2025-19-30",
payment_method = 1
}
};

request.AddJsonBody(body);

var response = await client.ExecuteAsync(request);
// Console.WriteLine(response.Content);

options = new RestClientOptions("https://api-staging.b2brouter.net/accounts/118004/invoices?offset=0&limit=25&type=IssuedInvoice");
client = new RestClient(options);
request = new RestRequest("");
request.AddHeader("accept", "application/json");
request.AddHeader("X-B2B-API-Version", "2025-10-13");
request.AddHeader("X-B2B-API-Key", "933bb5********f73392b");
response = await client.GetAsync(request);

Console.WriteLine("{0}", response.Content);