loader

In this post, we’ll go through how to use getURL tasks to retrieve content from other websites as part of the Zoho CRM custom function. As a fun little exercise, what I’m going to do is set up a custom function that will get the latest results from my local park run and email it to me. We do that by going into a custom function and writing out “url =” and then the URL. 

Then we write out “urlData = getUrl(url);” 

Then we will put in a “sendmail” task, email it to myself, and we’ll put the urlData in there.

Hopefully, this should send me a table with the data from the latest park run. Here’s the email that came through. 

You’ll see that it basically has all of the content from that webpage. The only difference is that it doesn’t have any of the styling. The reason for that is that you need to do inline styles in order to get an email to render the CSS properly, but we won’t really worry about that. The main purpose here was to show you the kind of things that are possible. 

I actually used this technique for one of my clients who wanted to send a nicely formatted HTML email. I set up a page in Zoho Creator, and then I used getURL to get the content out of that HTML page from Zoho Creator. Each page was dynamically generated based on the lead ID that supplied and it ended up working really nicely, so that’s one powerful thing you can do with getURL.

postUrl

Now, of course, getURL isn’t the only HTTP method out there. There’s also postURL. If you’re familiar with APIs, then you’ll know the difference between getURL and postURL. PostURL is great when you want to be sending data to another API. 

It’s a similar process here where you put in the URL and then you provide it a map which will have the data that you want to transmit. You can also give it header information.

Here’s an example of what you might do. 

If you want to send JSON data, you create your data payload as a map and then do payload.toString() so that it gets converted to JSON.

post_result = postUrl(url, payload.toString(), headers);

postUrl allows you to interact with any API out there that accepts a POST request.

Beyond GET and POST

There are many other HTTP methods out there: PUT, PATCH, DELETE to name a few. You can use the invokeUrl task to interact with API endpoints with other HTTP methods. Refer to the Zoho docs to learn more about invokeUrl.