Fixed the problems when modifying data

There was a missing header specifying that the content was json.
Also some pep8 fixes