Solved

How can I create a loop to iterate through this list?

  • 11 March 2021
  • 4 replies
  • 41 views

I have the first two pieces worked out thanks to some support from our community. Thanks again to @jdh for the support yesterday with JSON parsing.

 

My workbench features two API calls.

  1. GET JOBS LIST
  2. GET JOBS DATA

They both work, but GET JOBS DATA is currently hard coded for one job.

 

I'm trying to loop through features within an attribute (JOB_ID) so that the GET JOB DATA API call can be looped against the JOBIDs from the JOBS LIST.

 

How can I use looping to iterate a list of features into that API call?

 

Thanks in advance for any guidance you can provide!

 

WORK_BENCH_SCREENSHOT

icon

Best answer by jefejiraffe 12 March 2021, 15:43

View original

4 replies

Userlevel 3
Badge +17

Hi @jefejiraffe​ 

If I'm understanding your requirements correctly, you should be able to connect the fragmented output of the Job List response to the Job Data HTTPCaller. Each Job ID fragment should contain a Job ID attribute which you can then use in the Request URL parameter.

The Query String parameter is demonstrated here https://community.safe.com/s/article/Web-Services-cURL-and-the-HTTPCaller and is a matter of entering the Query String name and value in the appropriate column. For example:

HTTPCaller_QueryString

Hi @jefejiraffe​ 

If I'm understanding your requirements correctly, you should be able to connect the fragmented output of the Job List response to the Job Data HTTPCaller. Each Job ID fragment should contain a Job ID attribute which you can then use in the Request URL parameter.

The Query String parameter is demonstrated here https://community.safe.com/s/article/Web-Services-cURL-and-the-HTTPCaller and is a matter of entering the Query String name and value in the appropriate column. For example:

HTTPCaller_QueryString

Thanks for your reply Debbi! I updated the post yesterday after i more thoroughly read about the http caller. I wasn't understanding how it only appended to the end of the string at first. I now how that portion of the challenge solved. The last remaining element is to create a loop.

 

I've got a list of JOB ID's that come from a job list call to an API and I'm trying to create a loop on a second process that will iterate the first list. The second section at the bottom gets job data for a single JOB ID. I now want to iterate the list of JOB ID's that are a result of the upper portion, and generate an output that is the combined data for all JOB IDs. The looping transformer instructions are hard to understand so far. I keep reading and trying things, but it's a struggle. Hoping someone can give me the tip that unlocks it for me.

 

Thanks again for your reply to my original post. I realize I updated the text body, and still left the picture requesting syntax assistance. i'll update that now. Sorry for the confusion. I was trying to remove the query string portion of the question after I figured that part out.

 

Have a lovely Friday.

Userlevel 1
Badge +10

Thanks for your reply Debbi! I updated the post yesterday after i more thoroughly read about the http caller. I wasn't understanding how it only appended to the end of the string at first. I now how that portion of the challenge solved. The last remaining element is to create a loop.

 

I've got a list of JOB ID's that come from a job list call to an API and I'm trying to create a loop on a second process that will iterate the first list. The second section at the bottom gets job data for a single JOB ID. I now want to iterate the list of JOB ID's that are a result of the upper portion, and generate an output that is the combined data for all JOB IDs. The looping transformer instructions are hard to understand so far. I keep reading and trying things, but it's a struggle. Hoping someone can give me the tip that unlocks it for me.

 

Thanks again for your reply to my original post. I realize I updated the text body, and still left the picture requesting syntax assistance. i'll update that now. Sorry for the confusion. I was trying to remove the query string portion of the question after I figured that part out.

 

Have a lovely Friday.

There shouldn't be a requirement to create a loop, if you have a list from your first http caller you can explode this list so you have a feature per job id, then you send each of those features into the second httpcaller and use the job id to construct the http call. You may want a decelerator before the second HTTP call to limit the number of requests made per second

 

Capture

Thanks for your reply Debbi! I updated the post yesterday after i more thoroughly read about the http caller. I wasn't understanding how it only appended to the end of the string at first. I now how that portion of the challenge solved. The last remaining element is to create a loop.

 

I've got a list of JOB ID's that come from a job list call to an API and I'm trying to create a loop on a second process that will iterate the first list. The second section at the bottom gets job data for a single JOB ID. I now want to iterate the list of JOB ID's that are a result of the upper portion, and generate an output that is the combined data for all JOB IDs. The looping transformer instructions are hard to understand so far. I keep reading and trying things, but it's a struggle. Hoping someone can give me the tip that unlocks it for me.

 

Thanks again for your reply to my original post. I realize I updated the text body, and still left the picture requesting syntax assistance. i'll update that now. Sorry for the confusion. I was trying to remove the query string portion of the question after I figured that part out.

 

Have a lovely Friday.

It's true, I haven't updated yet. but immediately after trying it once more, I was able to pass things. working out the string concatenator to build the URL properly was the critical step I was missing yesterday. Thank you very much. The way the string query piece wants to build the URL was not helpful in this case and attribute creator with attribute concatenator was all I needed. the records flow from the top piece to the bottom and I have achieved the goal. Thank you very much for your reply! I'm posting an image of the work bench in case it might be helpful to anyone else that thinks they need a loop. ;D HAPPY FRIDAY EVERYONE! Solution

Reply