How to make Dynamic API Request with JSON

Database & APIs

Hi, I have a situation where I need to pass dynamic body data to my backend via API. We are creating a payment withdrawal API call where we need to withdrawal funds from several "goals" (we call them milestones). I need to make the goals dynamic and can vary in amounts that get passed in the payload and the withdrawal amounts will always vary. For example:

{
"accountId": "<account_id>",
"amount": <amount>,
"counterpartyId": "<counterparty_id>",
"secCode": "<sec_code>",
"userId": "<user_id>",
"description": "<description>",
"milestoneAllocations": {
"milestoneId1" : 50.00,
"milestoneId2" : 26.00,
"milestoneId3" : 17.00
}

}

In the above example, milestoneAllocations will always have a dynamic subset of data. It can have 1 or more milestoneIds and it will always vary. And each milestoneId will have an amount of money tied to it which will always vary. What's the best way to get this done? I'm open to changing my approach on it as well.

What have you tried so far?

I haven't tried much, I have simply created a list of String milestoneIds and a list of double amounts which I assume a value will be appended to it as needed? But it still doesn't really seem safe as something may go wrong with that implementation.

Did you check FlutterFlow's Documentation for this topic?
No
2
1 reply