Why can’t functions call internal Foundry APIs?

208 Views Asked by At

I am trying to write a Function on an Object that makes Foundry REST API calls. Is there an example or recommended internal Typescript API that I can import to make Foundry REST API calls?

1

There are 1 best solutions below

0
On BEST ANSWER

You can't make REST calls from Functions. This is for a few reasons:

  • By restricting which operations are available in Functions and running them in an isolated environment, Foundry can run Functions in a high-trust environment, which simplifies their execution model and allows for scalable execution
  • Functions are guaranteed to never have any side effects, which means they can be freely run at any time. If Foundry allowed itself to make REST calls, Functions could be used to modify state in any other API, which would make permissioning them and testing them very difficult.

If you are trying to access data that is available on other Objects, you could pass those Objects into the Function and use Objects.search() to search for the relevant object sets as a workaround.