Skip to main content
Solved

two API calls in a single automation

  • January 16, 2025
  • 5 replies
  • 109 views

fme_can_do_it
Enthusiast
Forum|alt.badge.img+9

I have set up an automation process that retrieves information from an API to generate a report. However, this task has become complicated because an essential piece of information we need to include in the report is located in a different API, which requires an ID to access the relevant data.

I am considering generating the report first, which will consist of the necessary IDs. Then, I plan to make a second API call to retrieve the information from the second API, one ID at a time. I have successfully completed the first part, but I am now stuck on the second part and unsure whether this can be achieved using FME or if a Python script is the only solution.

Best answer by hkingsbury

You can do this in the workspace using HTTPCallers. The first one will get the IDs and explode them into individual features - one for each ID. The features can then be passed to the second HTTPCaller where the ID attribute is used to form the request URL

View original
Did this help you find an answer to your question?

5 replies

hkingsbury
Celebrity
Forum|alt.badge.img+53
  • Celebrity
  • Best Answer
  • January 17, 2025

You can do this in the workspace using HTTPCallers. The first one will get the IDs and explode them into individual features - one for each ID. The features can then be passed to the second HTTPCaller where the ID attribute is used to form the request URL


fme_can_do_it
Enthusiast
Forum|alt.badge.img+9
  • Author
  • Enthusiast
  • January 17, 2025

@hkingsbury I extracted ID data from the first HTTP caller and created a list named `project_task_id` that contains all the IDs. Next, I used the Attribute Creator to create an attribute called "url," appending the `project_task_id` field to the end of the URL. I then passed this "url" attribute to the second HTTP caller in the Request URL section, but the request failed.

 


virtualcitymatt
Celebrity
Forum|alt.badge.img+35
fme_can_do_it wrote:

@hkingsbury I extracted ID data from the first HTTP caller and created a list named `project_task_id` that contains all the IDs. Next, I used the Attribute Creator to create an attribute called "url," appending the `project_task_id` field to the end of the URL. I then passed this "url" attribute to the second HTTP caller in the Request URL section, but the request failed.

 

Well you’re on the right track - most likely there is just something small you are missing. Check and double check your calls for typos. Hopefully the error you’re getting back from the API give you some hints as to what is going wrong. 

I’ve spent plenty of time banging my head against the wall with FME wondering why my API calls aren’t working only to notice my URL is off by a single letter or missing a key parameter required by the call.


s.jager
Influencer
Forum|alt.badge.img+16
  • Influencer
  • January 17, 2025
fme_can_do_it wrote:

@hkingsbury I extracted ID data from the first HTTP caller and created a list named `project_task_id` that contains all the IDs. Next, I used the Attribute Creator to create an attribute called "url," appending the `project_task_id` field to the end of the URL. I then passed this "url" attribute to the second HTTP caller in the Request URL section, but the request failed.

 

It could be something as simple as having a / at the end or not. I once ran into an API that made a huge difference between the url having a / at the end or not, so I agree with Matt. Check the documentation for the API carefully, build a url that you know works using your data, then try to replicate that url in FME. Using your browser or Postman can be very helpful here.

The basic structure you have is correct: I have workspaces that have to chain multiple calls to REST API’s, and it works just fine (1 search for an adress, 2 get details of address, 3 get link to building info, 4th get the building polygon + info). It can definitely be achieved using FME.


fme_can_do_it
Enthusiast
Forum|alt.badge.img+9
  • Author
  • Enthusiast
  • January 18, 2025

Thank you all for the assistance! I was able to correct the URL, and it worked. It was indeed a very simple thing that I been overlooking. 


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings