IBM Watson Natural Language Understanding

I was fiddling with code that worked with IBM Watson’s Natural Language Understanding API, and kept getting the following error:

    "error": "invalid request: content is empty",
    "code": 400

What happened is that I was calling out to IBM using the following requests Python code (post_data represents a Python object being encoded to JSON):

post_data_string = json.dumps(post_data), data=post_data_string, timeout=45, auth=(ibm_user, ibm_pass))

However, it seems that the API insists on having the correct request content type set; i.e. you must set Content-Type: application/json for the IBM Watson servers to notice there is a data body in the POST request. I fixed it by using the json parameter – the requests library for Python automatically inserts the application/json content type when this parameter is used. If you use a different language, you’ll need to set the proper content type in the language’s preferred manner., json=post_data, timeout=45, auth=(ibm_user, ibm_pass))

Why I Love NewsBlur – Folder RSS

After the closure of Google Reader – which I was a big fan of – I moved all of my RSS feeds to NewsBlur. One of the reasons I moved to NewsBlur is that it has a full API and is very easy to interface with!

For instance, folder feeds are available and don’t require authentication, making it easy for an app to merge multiple RSS feeds and treat them as one. For example: in NewsBlur, I’ve created a folder called economy and set up multiple feeds (New York Times, Forbes, Washington Post Business) underneath that folder, like so:

A Newsblur folder containing multiple feeds.
A Newsblur folder containing multiple feeds.

Right clicking the folder name and clicking folder settings pops up the folder settings tab. The URLs listed in the Feed Address section return a RSS list with all of the items from the feeds combined into a single feed. Even better: the URL supplied doesn’t require authentication, so an application can read it instead of having to poll 5 separate RSS feeds.

Newsblur folder settings screenshot.

Disney Waiting Page

I like to collect examples of error pages, but this is slightly different. When I was browsing, I was shown the below page asking me to wait until the request could be completed.

Notice the stylized Space Mountain image in the middle, which helps to customize and personalize the page to the Disney branding. This is a good page to use as a template if you need to build a similar long-waiting page.

Screenshot of a Disney page asking the user to wait while a long-running request executes.
Screenshot of a Disney page asking the user to wait while a long-running request executes.
A close-up of the stylized Space Mountain image, which helps to brand the page with the Disney theme.
A close-up of the stylized Space Mountain image, which helps to brand the page with the Disney theme.

Google Shoppable Ads – Competition For Pinterest

In light of Pinterest’s recent IPO, I wanted to point out an article from Mobile Marketer: .

Monetizing Pinterest will largely come down to showing relevant ads within user searches – for example, showing an ad for wedding supplies within an user search for wedding ideas. However, we see Google moving into this business as well, as highlighted in the above article. Google will be showing more ads within Google Images searches – but more importantly – those ads will be image based, which should help clickthrough and purchase rates.

I fully expect Pinterest to thrive and grow, but we’ll be seeing a fair bit of competition from Google and others as well.

Amazon Error Pages

As I’ve said before, I love documenting error pages from popular web sites: they often have a sense of humor or show off another face of the company.

Here’s an example of an Amazon error page. What a handsome looking dog!

An Amazon error page.

Amazon Cloud9 IDE Python 3

I spent today morning pulling my hair out trying to get a Python 3 application running within AWS’ Cloud9 IDE. Essentially the problem is that if you pip install some-package, that package only becomes available within the Python 2 runner, not within the Python 3 runner (the current Cloud9 machine image includes Python 2 aliased as python, and Python 3 available through python3).

Fortunately for me, someone else had the same problem, and an Amazon staffer suggests creating a virtual environment: . I followed the steps mentioned, but it didn’t work – pip still installed dependencies for Python 2. I wonder if this staffer forgot to mention another step, such as remapping the pip command to a Python 3 install.

What finally did work was calling the pip command through the python3 interpreter, like so:

First, ensure pip is installed:

python3 -m ensurepip --default-pip    

Then upgrade pip:

python3 -m pip install --upgrade pip setuptools wheel

Then you can install any requirements of your app, such as BeautifulSoup:

sudo python3 -m pip install --upgrade bs4

And after all that, my Python 3 app was able to access the BeautifulSoup dependency.