I'm able to create Purchase Orders using the API without any issues. I can also create purchase orders with a single approval level. Where I'm struggling is when trying to create a purchase order with multiple approval levels. At this point I've run out of ideas and would love any input. Thanks!
What I've tried so far
I tried following the API documentation but haven't been having much luck.
https://apidoc.samanage.com/#tag/Purchase-Order/operation/createPurchaseOrder
"approval_levels_attributes": [
{
"id": "1",
"approver_ids": "1, 2",
"approval_condition": "1"
}
],
With some trial and error, I was able to figure out the following:
- I'm not sure how
id
is used, and leaving undefined still allows creating a PO with a single approval level. approver_ids
is a comma separated string of "group" ids for the different approvers.approval_condition
seems to be the "Only one approver", "All approvers", or "50% or more approvers"

I initially assumed each "level" would just be defined as a separate item in the list, but that actually doesn't work and sort of breaks the approvals, creating a duplicate of the Level 1 approval that the system ignores .
"approval_levels_attributes": [
{
"approver_ids": ""6712085",
"approval_condition": 1
},
{
"approver_ids": "6712085,6828711",
"approval_condition": 1
}
]

I also tried checking the network traffic when submitting from the web. Submitting a PO with these approval levels were submitted as a form with this attribute breakdown:

I tried resubmitting as a list of approval levels in the two following ways:
- This payload actually ended up having the same error as submitting list the list of approvals above, with a duplicate Level 1 approval.
"approval_levels_attributes":{
0: {
"approver_ids": data.pop("approvers"),
"approval_condition": 1
},
1: {
"approver_ids": "6712085,6828711",
"approval_condition": 1
}
}

- This payload, the closest to the actual documented payload, weirdly gave me a 404 error...
"approval_levels_attributes": [
{
"id": "0",
"approver_ids": "6712085",
"approval_condition": 1,
},
{
"id": "1",
"approver_ids": "6712085,6828711",
"approval_condition": 1,
},
]