httpPostJson Convert Python to Groovy

I have a python script that contains the following:

    x = eg.event.payload[1]
            response =


                headers={'x-ha-access': 'mypassword', 'content-type': 'application/json'},

                data=json.dumps({'state': x, 'attributes': {'hidden': 'true', 'friendly_name': 'the period'}}))
            print ("%%%%%% HA Connection Error %%%%%")

I have tried to convert this to groovy and have not had any success. Here is the last of many attempts

def params = [
    uri: "",
    path: "/api/states/sensor.hem_theperiod",
    headers: ['x-ha-access': 'mypassword','content-type': 'application/json'],
    data: ["'attributes': {'hidden': 'true', 'friendly_name': 'the period'}, 'state': '4'" ]
log.debug "Calling HAS"
httpPostJson(params) { resp ->
        resp.headers.each {
            log.debug "${} : ${it.value}"

        log.debug "response contentType: ${resp.contentType}"
log.debug "HAS called. $response"

This and many other attempts have failed. I am looking for some help tho get the above python code converted to groovy,

Thanks in advance