Click here to Skip to main content
13,801,663 members
Click here to Skip to main content
Add your own
alternative version

Tagged as


3 bookmarked
Posted 30 May 2013
Licenced CPOL

Error Reporting with PushingBox

, 30 May 2013
Rate this:
Please Sign up or sign in to vote.
I’ll explain a little about this free service and show you some sample code of how to integrate it into your applications or automation scripts using Powershell.

One of my users let me know they were using a cloud service called PushingBox to be notified of events in Directory Monitor. I investigated what it can do and immediately thought of a couple of interesting use cases for this service. One of those use cases being the ability to send errors to yourself from your own software in the wild. I’ll explain a little about this free service and show you some sample code of how to integrate it into your applications or automation scripts using Powershell.

The PushingBox Service

PushingBox is a free service to anyone with a Google account. You can login and it will generate a demo email scenario for you automatically. There are however many more services you can link up to including popular iPhone and Android notification apps and even Twitter. The API is simply an HTTP GET or POST using the “DeviceID” assigned to your scenario and optional parameters that you can use to augment your push messages.

Setting up a Basic Scenario

To get an email for errors in your application, setup a simple email scenario in PushingBox (My Scenarios –> Create scenario). You can use parameter names enclosed in $ signs for replacement when you make a call to the service (remember this isn’t limited to just email):

PushingBox scenrio

Now you can use parameters with the same name in the URL or in your POST and they will be replaced with those values when the email arrives in your inbox. When you’ve setup the scenario, remember to grab the “DeviceID”, you’ll need that to make a request to the service.

Making the Service Request in C#

The code to make a HTTP POST in C# (or .NET in general) is very easy. Here is a basic static method (using statements left out for brevity) that will POST an exception to the service, remember to use your own devid in place of “YOUR_DEV_ID_HERE”.

public static class PushingBoxHelper
  public static void PushError(string version, Exception error)
    Contract.Assume(error != null);

    // Fire and forget
    Task.Factory.StartNew(() =>
        var post = new NameValueCollection();
        post.Add("devid", "YOUR_DEV_ID_HERE");
        post.Add("version", version);
        post.Add("error", error.ToString());

        using (var wc = new WebClient())
          wc.UploadValues("", post);
      catch (WebException we)
        Log.Error("Failed to submit error information to PushingBox.", we);

Now, whenever you get an error or unhandled exception in your application that you want to get notified about, just call the PushingBoxHelper.PushError method and it will quietly try to push the information to PushingBox’s API so you will get an email or a push to any other service you have configured.

Making the Service Request in Powershell

If you do not want to write any code or just need to push a notification from a script, you can easily use any of the examples on the API section of their site. I opted for a Powershell script since I wouldn’t need any other dependencies such as Python, cURL or PHP.

Be careful of doing a GET since you will need to encode the parameters correctly otherwise data may get lost. This is the Powershell code to make a GET request:

# GET Method #
param (
  [string]$version = "",
  [string]$err = ""

begin {
  [System.Reflection.Assembly]::LoadWithPartialName("System.Web") | out-null
  $get = ""
    + [System.Web.HttpUtility]::UrlEncode($version) + "&error=" 
    + [System.Web.HttpUtility]::UrlEncode($err)
  (new-object System.Net.WebClient).DownloadString($get)

In the same light, you could also POST from Powershell in a very similar way. I prefer this because it’s cleaner and you don’t need to encode anything, it will happen automatically for you:

# POST Method #
param (
  [string]$version = "",
  [string]$err = ""

begin {
  [System.Reflection.Assembly]::LoadWithPartialName("System.Web") | out-null
  $post = new-object System.Collections.Specialized.NameValueCollection
  $post.Add("devid", "YOUR_DEV_ID_HERE")
  $post.Add("version", $version)
  $post.Add("error", $err)
  $wc = new-object System.Net.WebClient
  $wc.UploadValues("", $post)

You can execute this script from the command-line using the named parameters to send the information you need:

powershell -file pushingbox.ps1 -version "" -err "Something went wrong!"


I think this is an awesome service that could be used for a variety of scenarios where you would want instant notification via multiple channels when something interesting happens. Breaking builds triggering a Karotz, automating Tweets when you create a blog entry, there are so many… They also provide the source for certain Arduino shields so you can push notifications due to electrical/mechanical interaction with the environment. Check out the videos on the home page for more cool ideas.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Werner van Deventer
Founder DevEnterprise Software
South Africa South Africa
No Biography provided

You may also be interested in...

Comments and Discussions

-- There are no messages in this forum --
Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web02 | 2.8.181215.1 | Last Updated 30 May 2013
Article Copyright 2013 by Werner van Deventer
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid