Blog

Thursday, August 23, 2012
Zoho CRM REST API
I have about a dozen programming-related items floating around in my head that I'd like to write up short blog entries about. Maybe I'll manage to get one or two written up tonight.

I've been doing some work recently with some random REST APIs. When I'm calling REST APIs from .NET, I like to use EasyHttp. Based on the stats on its NuGet page, I guess it's not that popular, but it's updated often enough, and it works well for me.

I recently worked on a project where I had to create a lead in Zoho CRM, using their API. I had a little bit of trouble, but only because I didn't have quite the right parameters set -- it turns out that "newformat=1" is really important. I had looked for some sample C# code for the Zoho API when I started this, and didn't find any, so I thought I'd post a quick Gist with my code:

I'm not sure I've even embedded a Gist here. I hope it works OK.

I'm also using log4net here.  I'm a really big fan of log4net, and I use it in almost all of my projects. I have a pretty standard log.config file I use that sets up a RollingFileAppender, with ten files of 100k each. That's usually enough to keep a few days or weeks worth of history, depending on the level of logging and the level of activity. And I never have to worry about the log files growing out of control; they just keep rolling over. I think log4net is pretty popular, based on the numbers on their NuGet page.

I try to do a lot of error-handling whenever I'm dealing with a REST API. There are plenty of things that can go wrong. You can see in the code above that I try to trap anything that might throw an exception and log it. I'm never sure if I'm doing this the "right" way. I know some people, when writing a routine like this, would just let the exceptions happen, then have a try/catch around the call to the CreateLead method, and deal with it at a higher level.

Labels: ,

posted by Unknown 8:18 PM
0 comments

Comments: Post a Comment


This page is powered by Blogger. Isn't yours?
© 2011 Andrew Huey