How to resolve data_path when inserting keyframe in my situation? def testAnimation():

  scn = bpy.context.scene
  arm = bpy.data.armatures["Rig"]
  rigobj = bpy.data.objects["Rig"]
  scn.objects.active = rigobj
  rigobj.select = True

  bpy.ops.object.mode_set(mode = 'POSE')

  boneSelect = bpy.context.object.data.bones['RThigh']
  boneSelect.select = True

  bpy.ops.transform.rotate(value=(0), axis=(1.0,1.0,1.0))
  boneSelect.keyframe_insert(data_path = "location", frame = 0.0)

  bpy.ops.transform.rotate(value=(math.pi*0.5), axis=(6.0,80.0,40.0))
  boneSelect.keyframe_insert(data_path = "location", frame = 100.0)

  bpy.ops.transform.rotate(value=(math.pi*0.5), axis=(1.0,0.0,0.0))
  boneSelect.keyframe_insert(data_path = "location", frame = 200.0)


  bpy.ops.object.mode_set(mode='OBJECT')
  scn.update()


I have tried placing many variables in data_path, but it comes up with a TypeError. What should I place in my data_path for it to take the new transformation?

Thank you for your time.
You need .pose in your path, like this:

bpy.data.objects["Rig"].pose.bones['RThigh'].keyframe_insert(data_path='location')


This is because the Edit bones and the Pose bones have separate data while sharing some common attributes.