Rotate an object around an axis

I try to rotate and translate objects and then insert a keyframe by calling the function below:

def set_keyframe(frame_no, x, y, rotation_z, object_id):

    # change frame
    bpy.context.scene.frame_current = frame_no  

    # select the object
    currentObject = bpy.data.objects[object_id]
    currentObject.select = True

    # translate and insert keyframe
    currentObject.location.x = x
    currentObject.location.y = y
    currentObject.keyframe_insert('location')

I could manage to translate the object, however I couldn’t find out how to perform the rotation operation. I am just trying to rotate around z axis. I tried to do it using the object’s matrix_world in order to simultaneously translate and rotate the object. However, I couldn’t manage to rotate around an axis and to insert a keyframe. Any help, which may not necessarily use the matrix_world, would be appreciated!

I have just realized that the issue was due to a constraint that I have previously defined… Now it works