Posting more than one colum with Loops

Hello,

I used Post request method in a loop by taking one column as an identifier(ID) and other column as a JSON data which needs to be posted. Now, I would like to use the same method by various columns of data. I am wondering if there is a way to loop over different columns ? Please find attached snap of my table. EHR contains the ID, Colum is the Topic and Json cells are Data which needs to be posted.

Best,
Mateen

Hello,
This is possible with a Column List Loop Start. It outputs the current column name as flow variable that you can use in the POST Request node.
Kind regards
Alexander

Hi @AlexanderFillbrunn,

Thanks for quick reply. It is working as I was expecting but only once. As you can see in the snap attached, I would like to change the Post URL on the fly thus I am using Java Edit variable, when I connect Column list to Java Edit directly, I got some other errors (Java Edit doesn’t recognize the excluded columns which I need as part of URL). Loop End is running the internal Loop. I tried to put another Loop End but that’s also not working.

Hi,
If you use the Table Row To Variable Loop Start, the variable name will change in every iteration because it gets the name from the column name. The current column is output as variable from the Column List Loop Start. You can use it to build a custom expression for the Java Edit Variable node (or better, use a String Manipulation (Variable) or Math Formula (Variable) node if possible). The expression can then again be passed as flow variable to the POST Request node. Alternatively, you can rename the current column to a fixed value, so that it is always the same name in your expressions.
Kind regards,
Alexander

Hi @AlexanderFillbrunn,

With Table To Row Variable Loop Start, I am passing the URL components (to concatenate with Java Edit node later) and the data itself (JSON body) (URL components are marked with Red).

Column List Loop start only offers only one Flow variable (Body) even though it shows three columns in output (2 should be used for URL, 1 Data Body).

ColumnList_Output

I am not sure if it’s passing the other two as they can’t be seen in the section.

The problem is if it doesn’t pass the URL components how can one use String Manipulation or any other Node afterwards ?

Hi,
I think the easies way to solve this is to use a Column Rename (Regex) and use the flow variable with the current column name as pattern, then rename that to a fixed name, e.g. JSON_BODY. Now you can use the two static columns and the column JSON_BODY in your expressions.
Kind regards,
Alexander

Hi @AlexanderFillbrunn,

Please find attached workflow as unfortunately I couldn’t figure out further steps because Column List Loop start was not passing any Flow variable (other than current column).

Best,
MateenTest_Post.knwf (35.9 KB)

Hi,
Please find attached the solution. You don’t need any flow variables. Just rename the JSON column using the Column Rename (Regex), then use a normal Java Snippet to build the URL. That can then be passed to the POST Request.
Kind regards,
Alexander

Test_Post.knwf (15.0 KB)

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.