What is the best way to set up a REST API call in APEX? I am trying to use the Google Translate API (basic) to send it text string(s) (queried from database into a Display Only page item) and target language code, and then have it return the translated string for me to replace in the DOM.
The url API call is:
https://translation.googleapis.com/language/translate/v2?key=[api_key]&source=[en]&target=[es]&q=[This is a sentence to be translated.]
I first set it up as a REST Data Source, but now thinking this is not the best way to do this as I do not know how to dynamically change the query params and then handle the JSON response that is returned. A REST Data Source seems to be more of a static data fetch in regards to the same params used for each call.
What is the best way to call a REST API? Pass in params dynamically? and then deal with the response? Ideally I would like to set this up in a way so that the whole app can reuse it.
I am trying to understand the differences (or different uses cases) for:
- REST Data Sources (Shared Components)
- REST Enabled SQL (Shared Components)
- Legacy Web Service References (Shared Components)
- RESTful Services (SQL Workshop)