Pass url when creating a resource

It is needed even if it is a direct upload, otherwise you get a
Validation error.

Also print errors from the API, otherwise is hard to know what is going
on.

Some PEP8 as well.