New for Sugar 6.5: SugarHttpClient

sugarcrmdevelopers —  May 11, 2012 — 18 Comments

One of the biggest complaints I’ve heard recently is around the changes made to the Module Scanner in the product, which is strictly enforced in our On-Demand environment, namely about the inability to use curl or file_get_contents() directly to do outbound web service calls. For example, check out this example of making an outbound call from PHP to the Sugar Web Services API using curl:

Not only are there potential issues with curl usage on OD, but there’s a lot of code to make this happen. Pretty inefficient…

Now in Sugar 6.5, we’ve helped out developers out by adding the SugarHttpClient object, which is a simple way to make POST HTTP calls in Sugar without having to get down in the weeds with curl or file_get_contents(). Check out the above example re-written to use this instead:

You can see the code is now much cleaner, without all the bits around curl out of the picture.

We recommend that if you are doing any simple outbound web service calls in your customizations, you should use SugarHttpClient in Sugar 6.5 versus curl or file_get_contents() directly to avoid Module Loader restrictions. If you have more in-depth requirements such as needing to pass OAuth tokens, then building a Sugar Connector and leveraging the External API will add the additional features such as a user configuration UI that you’ll want to use.

18 responses to New for Sugar 6.5: SugarHttpClient

  1. 
    Wesley Curtis May 15, 2012 at 6:09 pm

    Is disallowing curl a recent development? Some of the code we’ve been writing lately has used it extensively, and we have yet to have any issues with OD deployment.

    • 

       I don’t believe curl specifically is banned at this point, but file_get_contents() is. Nonetheless, using the built-in Sugar library is a best practice going forward.

  2. 

    Between SugarHttpClient and a new Sugar Connector I think that we could also use Zend_Http_Client included in SugarCRM to have more capability to add curl_option (to add proxy setting by example) or what ever you want.

  3. 

    Now file_get_contents(). Yet another PHP function that I use in the Google Maps project banned by SugarCRM On-Demand. You’re not making this easy on me to provide, for free, a package that will install on “your” clients’ SugarCRM On-Demand instances. Are you using my project to determine the functions to ban or am I just “lucky”? 🙂

  4. 

    Is there any way to get muliple curl request this way?

  5. 

    For My application , i need to have more than 10k records from get_entry_list , and then save in local db , OD is getting timeout in this process . So i need to have Multiple CURL requests.
    Let me know any ideas!

  6. 

    Hi, it looks like the SugarHttpClient is designed very much with POST requests in mind. What would you recommend as best practise when making a simple GET request?

  7. 
    disqus_PAkBoCjv5P May 9, 2013 at 12:07 am

    How to ‘DocumentRevision’ to the ‘Sugar Feed’?

Trackbacks and Pingbacks:

  1. urgent help with my curl script!!!! - July 9, 2012

    […] […]

  2. can not connect to host in custom module - July 16, 2012

    […] […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s