Adding information to the body of an API call

I'm trying to dynamically add lines to a API call's body, I have a + button that is working to add additional lines. But I'm lost on how I can actually add those additional lines to a specific body text. I'm pretty new to all of this so baby steps are appreciated

I have boxes and drop down values in the application itself and have mapped them to the values within the dhcpOptions body text. This works perfectly fine, the problem is that we always have to use all 3 options. So if I wanted to only use 1 row of "type,code,value" I would have to go into the app itself and remove the additional text from the dhcpOptions body.

To help this I created a +/- minus button that adds/subtracts rows based on what you need.


Issue 1 - The new values of that button look to be exactly the same as the original. Meaning if my original row was DHCP_code_input1 when I click the + button it will create another box of the same name, DHCP_code_input1.

Issue 2 - How do I place the newly created values into the correct header. I had messed around with JS using the push command but regrettably my JS is pretty weak so I hit a wall pretty fast. Below is a image I was using for testing. This kind of worked but it just put the same values at the end of the original string.

Hi @evanhouten Thanks for reaching out!

I'm not sure how you have the rows set up, but I'd recommend using a listview with a dynamic length of rows. Let me know if you have questions about using a listview! I am imagining it similar to this temp state suggestion

Then, you can map over the listView data to create your body text. For example, I have two rows that I am mapping over in my transformer to create an array with 2 objects:

With this implementation, you won't have to worry about not having enough rows or having too many rows.

This is working awesome thank you!!!!

So while putting this into the app I ran into a slightly different format in the API call that is throwing an error. In the body of one of the calls there's no label like "type" and is just a value. In this case the Body is "fixedIpAssignments" the next line has the MAC address of the device but their's nothing defining it like all the other calls.
image

I tried modifying it a little bit but it doesn't seem to like it without a string attached.

Hey @evanhouten! Glad that helped :slightly_smiling_face:

Does something like this work (adding square brackets around the first key and curly brackets around the nested key value pairs):