Various fixes

There are a couple syntax errors in the Erlang code. This fixes them. It also corrects the URL for the API endpoint and uses the stdlib function for encoding the URL.