def METHOD_NAME(module):
    url = "https://api.newrelic.com/v2/applications.json"
    data = "filter[name]=%s" % module.params["app_name"]
    headers = {
        'Api-Key': module.params["token"],
    }
    response, info = fetch_url(module, url, data=data, headers=headers)
    if info['status'] not in (200, 201):
        module.fail_json(msg="Unable to get application: %s" % info['msg'])
    result = json.loads(response.read())
    if result is None or len(result.get("applications", "")) == 0:
        module.fail_json(msg='No application found with name "%s"' % module.params["app_name"])
    return result["applications"][0]["id"]