RDD element of type java.lang.String cannot be used error

Hello Guys,

I am trying to save as textfile using saveAsNewAPIHadoopfile() method. But I am getting error as follows.

RDD element of type java.lang.String cannot be used

I have imported departments table from mysql and have stored in hdfs. I am using below syntax for reading and storing in hdfs by python in spark.I am not able to figure out the error. Your help will be appreciated.

dept = sc.textFile("/user/cloudera/sqoop_import/departments")
dept.saveAsNewAPIHadoopFile("/user/cloudera/pyspark/dept_seq_api",“org.apache.hadoop.mapreduce.lib.output.textOutputFormat”,keyClass=“org.apache.hadoop.io.Text”,valueClass=“org.apache.hadoop.io.Text”)

Note: I have already used saveAsTetFile() without any error.

Thanks
Ansuman