Debugging SendGrid’s Parsing Incoming Messages

SendGrid has a nice feature available to it’s Silver Level Subscribers and above (currently $79/month) that let’s you have incoming message to a domain parsed and forwarded through a web service.  This is great if it works but if it does not debugging is tricky because the web service is running on your production server.

image

Here are some steps to debug the service.

Go to the URL:  http://requestb.in/ and then use the URL given to you as the email forwarding URL inside of the SendGrid Control panel.

image

image

Then, send an email to your domain you want to parse (siliconvalley-codecamp.net in my case).

Head back to the requestdb.in page and look at the request.

Copy the headers into the fiddler compose request page, then the body into the data area.  You can now post this to your real web server running locally to see what happens.

image

For some details on what the web service might look like in ASP.NET WebAPI check out this post:  http://www.altifysoftware.com/receiving-emails-using-sendgrid-inbound-parse-c-webapi2/.  I’d do a little more error checking than done here and also remove some extra code.  Otherwise, it works great.

HTH’s!

Google Chrome Extension Clear Cache, My Pick!

I’ve been listening to the podcast recently Adventures in Angular and in particular the “Podcaster Picks” at the end of each podcast.  At first I thought this was pretty silly but have been surprised that many of the picks I did not know about and have been quite useful.  So, in the Holiday spirit of giving, here is my pick for the day.

Clear Cache from Benjamoin Bojko

Motivation For Needing this

I’ve been doing a lot of JavaScript programming for the past couple years and Chrome Dev Tools is my debugger of choice.  It’s amazing easy to clear cache which is something I do quite often.  To be clear, all I have to do is:  1) Tools Pull down then 2) select “clear cache” and finally 3) select the URL in the browser and press refresh.  I just timed this and it takes me about 2.5 seconds.  I could do the keyboard short cuts and maybe shave it down to 1.5 seconds but I switch back and forth between OSX and Windows quite a bit and the key strokes are slightly different so I just do the menus.

Today, I decided to spent 5 minutes hunting for a chrome extension thinking I could use a little more DRY (don’t repeat yourself) in my life and shave a second off my life.

Why I Like Clear Cache

  • It has lots of users so it likely gets attention
  • It puts itself on my toolbar
  • It only requires one click to execute
  • It refreshes the current URL after clearing just the parts of cache I want

image

Very nice!  HTH’s.

WebAPI REST Routing For AngularJS and ExtJS

As most of my readers know, I’ve done a lot of work with the JavaScript libraries made by Sencha (ExtJS and SenchaTouch).  The typical JSON sent down to the requesting web application looks like the following with both Sencha products.

Notice that it is a single JavaScript object that has a property named data which is the array we are interested in.

AngularJS’s Resource api expects just the data array by default without the nice wrapping with total and status.  That is, Angular just wants this:

The default routing in Microsoft’s ASP.NET WebAPI 2 is such that a rest controller always formats data the same and it is non trivial to write a special filter to convert the results to one format or the other based on something like a request header.  The work around I came up with to allow basically one WebAPI service to handle both types of output was to have the REST call be slightly different.  The original REST calls to get data were as follows:

…/rest/ShirtSize and …/rest/ShirtSize/31

That is, the two above URLs always get me the full result including the total and success value.  What I want is another REST call I can use in AngularJS that will return me just the array.  My design calls for the following two URLs to do that.

../rest/ShirtSize/ArrayOnly and /rest/ShirtSize/ArrayOnly/31

To do this in WebAPI is quite simple.  All we need to do is add to our routing file (WebApiConfig.cs) the following code.

Then, in our WebAPI controller itself we have the following method signature.

Now, when the WebAPI call happens without arrayonly specified we get the default behavior which includes the success and count but when arrayonly is passed in the parameter line we can return a custom response that just has our array.

HTH’s!

Why Refactoring Support in a JavaScript IDE Is so Important

As I’m building out a new version of the Silicon Valley Code Camp web site in AngularJS, I’m running into the very common case where I have not created my program files hierarchy optimally.  What I have now (as seen from JetBrains WebStorm) is the following:

image

I realize now that I’m adding the login screen that I really should have an app folder account and registration should be a subfolder of that.  To make that change without a good tool (like WebStorm), I would need to go into my file manager and copy the files I want, then go into my index.html file and manually change all those directory references.  Likely (because I’m not that good at that kind of work) I’d make at least one mistake and have to come back and revisit the issue again.

With WebStorm, I simply drag and drop the JavaScript files (after creating a new directory) and the index.html references are automatically cleaned up for me.

Just Sayin…

Plugin by Social Author Bio

Follow

Get every new post delivered to your Inbox

Join other followers: