im trying to make an API where i can send invoices to another application.. and im struggling with how bubble understand when i want to send multiple arrays/invoice lines in the invoice
In api connector
For the productline parameters in action, you should use
Do a search for productline:format as text
in the format as text, you will set, on the top box:
{
"description": "This item description(dynamic)",
"quantity": This item quantity(dynamic),
"accountNumber": This item accountnumber(dynamic),
"unit": This item unit(dynamic),
"discount": This item discount(dynamic),
"lineType": This item linetype(dynamic),
"baseAmountValue": This item basemountvalue(dynamic)
}
(I didn’t add doubles quotes everywhere… so check API documentation to add them where it’s needed)
on the bottom box, just put a comma (as delimiter)
Please… read again… I show you using a do a search…in your case, it’s
Current page’s case’s invoice lines:format as text that goes in the (body) productlines field
You will set the JSON of productlinein the format as text function…
In API connector, you seem to have set the correct value to initialize the call (The json object). (But if you already have it initialized, you don’t need to initialize it again)
Yes and no
For sure, you will have an error in your JSON. "lineType" is a string accordin to your screenshot, so product need to be double quotes around it "linetype":"Product", Like I said, in my JSON, I didn’t set them because I don’t know what API expect. Check API Doc to be sure you are creating the JSON correctly.
For description, be careful if you expect special characters that could break the json.
You could instead do: "description":This innvoice list's name:formatted as JSON-safe,. As you can see, I didn’t set double quotes around This invoice list’s name:formatted as JSON-safe because this function will add them automatically but also escape special characters.
aaah.. that make sense.. learning something new today
then i have another question also because in the documentation it says units only accepts: hours, parts, km, day, week, month, kilogram, cubicMetre, set, litre, box, case, carton, metre, package, shipment, squareMetre, session, tonne.
but in my application i use: “timer, stk, kvm, uger, måneder” and so on.. so danish definitions of them.. is there a way to make the API understand that?
Create a new field in your option set and translate the display value into something API accept.
In your unit parameters use This units(option set)'s new field instead of 's display (use the name of the field you set )
Go in option set for your units (seem to be called enheder)
Click on Create a new attribute. Let’s call it “Dinero API Unit”. Select “text” for the type
Click on modify attribute of each of your “enheder” Add the value for each of time in this new field using the accepted value by API. Let’s say “timer” will be “hours”
Now in your JSON, modify "This invoice list's enheder's display" For: "This invoice list's enheder's Dinero API Unit"
but okay its authorized again..
and now i get this message:
{"code":42,"message":"Validation Error","validationErrors":{"Body":"The body does not match expected schema"},"languageSpecificMessages":[{"property":"message","message":"Der er fejl i de data, du har angivet."},{"property":"Body","message":"The body does not match expected schema"}],"errorMessageList":[{"Code":"Body","Message":"The body does not match expected schema"}]}
showLinesInclVat should be false without double quotes. Same for paymentConditionNumberOfDays. However, this is possible that the API accept boolean and integer as string.
You can use tools like beeceptor or requestbin to send the request and inspect it.
This will be easier to find what can be the issue but also to validate the JSON