httpCallExternal (url, verb, content, headers)

Call an external URL from the mytaglist.com service.

Arguments

url: An global URL that begins with "http://" or "https://"

verb: The HTTP verb to use, must be either "GET", "PUT", "POST" or "DELETE".

content: Optional content to upload for PUT or POST verb. If the content starts with "{" or "[", i.e. it looks like a JSON format, the content type will be automatically set to "application/json", otherwise, to "application/x-www-form-urlencoded".

headers: Optional Javascript object to specify arbitrary HTTP request headers. For example:
{ "User-Agent": "MyBot" ,  "Content-Type": "text/plain" }
Note to specify this, the content argument must not be omitted (can be null or empty string) as this is the fourth argument.

Returns

The HTTP response as string. If you are calling JSON (REST) web service, you can directly pass the returned string to JSON.parse to convert it to Javascript object for further processing. For example, a public web service at http://api.sunrise-sunset.org/json?lat=36.7201600&lng=-4.4203400&formatted=0 returns the sunset/sunrise time of the day at given coordinate. It will return a string like this.

To extract just the sunset time, use

JSON.parse(KumoApp.httpCallExternal("http://api.sunrise-sunset.org/json?lat=36.7201600&lng=-4.4203400&formatted=0")).results.sunset

This is a ISO8601 string which you can pass to new Date() to get the Javascript Date object.

Remarks

To call an HTTP endpoint that resides within a Firewall or on a private IP address/network together with the Tag Manager, use KumoApp.httpCall.