import requests
import json


def add_param_to_group(base_url, gid, pname, pval):
    """
    adds a param to a group in NodeMeister, returns True on success or False on failure
    """
    if pval.strip() == "" or pval == "" or pval == "''":
        pval = None
    payload = {'group': gid, 'paramkey': pname, 'paramvalue': pval}
    headers = {'content-type': 'application/json'}
    r = requests.post("%senc/parameters/groups/" % base_url, data=json.dumps(payload), headers=headers)
    if r.status_code == 201:
        return True
    return False