Foreman 1.3 api

Using foreman 1.3 the api changed and therefore broke the script. I refactored the json calls but didn't tested it on foreman 1.2..