Invalid Ticket Id
Invalid Ticket Id
I'm a new Zoho developer trying to call the CRM API. I've followed your example by substituting Contacts instead of Leads (which we don't use yet) and adjusting the column names. My code in java is below.
I've found some other tickets like this, and I have tried:
- generating a new Zoho Service Communication (ZSC) Key
- copying the token from
https://accounts.zoho.com/u/h#sessions/userauthtoken (which does not match the ZSC)
But no matter what token I try I get the same error: 4834 "Invalid Ticket Id".
Can someone help me get this data pull working? Thanks in advance.
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.ConnectException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.logging.Level;
import java.util.logging.Logger;
public class ZohoGetRecordsDemo {
private static final String AUTHTOKEN = "---copied from Zoho account---";
public static void main(String a[]) {
String selectColumns = "Contacts(Contact Owner,First Name,Last Name,Email)";
String fromIndex = "1";
String toIndex = "50";
String targetURL = "
https://crm.zoho.com/crm/private/xml/Contacts/getRecords";
Logger logger = Logger.getAnonymousLogger();
try {
URL server = new URL(targetURL);
HttpURLConnection connection = (HttpURLConnection)server.openConnection();
connection.setRequestProperty("authtoken", AUTHTOKEN);
connection.setRequestProperty("scope", "crmapi");
connection.setRequestProperty("newFormat", "1");
connection.setRequestProperty("selectColumns", selectColumns);
connection.setRequestProperty("fromIndex", fromIndex);
connection.setRequestProperty("toIndex", toIndex);
connection.connect();
if (connection.getResponseCode() == 200) {
String response = streamToString(connection.getInputStream());
System.out.println(response);
connection.getInputStream().close();
} else {
logger.severe("http error: " + connection.getResponseCode());
}
} catch (ConnectException e) {
//assume this is a timeout and log simply
logger.severe(e.getMessage());
} catch (Exception e) {
logger.log(Level.SEVERE, "an error occurred while calling zoho", e);
}
}
public static String streamToString(InputStream inputStream) {
//from:
http://stackoverflow.com/questions/309424/read-convert-an-inputstream-to-a-string
java.util.Scanner s = new java.util.Scanner(inputStream).useDelimiter("\\A");
return s.hasNext() ? s.next() : "";
}
}