Issue in updating records
I am trying this code to update the record in leads.
Using the ZSC key in authtoken. But I get this error "HTTP Response status code: 200
>> Time taken 5121
15-Feb-2013 16:37:58 org.apache.commons.httpclient.HttpMethodBase getResponseBody
WARNING: Going to buffer response body of large or unknown size. Using getResponseBodyAsStream instead is recommended.
postResp=======><response><error><code>4600</code><message>Unable to process your request. Please verify whether you have entered proper method name,parameter and parameter values.</message></error></response>
"
Code:
import java.io.*;
import java.util.*;
import java.net.*;
import org.apache.commons.httpclient.*;
import org.apache.commons.httpclient.methods.*;
import org.apache.commons.httpclient.methods.multipart.Part;
import org.apache.commons.httpclient.methods.multipart.FilePart;
import org.apache.commons.httpclient.methods.multipart.StringPart;
import org.apache.commons.httpclient.methods.multipart.MultipartRequestEntity;
import org.apache.commons.httpclient.methods.multipart.PartSource;
import org.apache.commons.httpclient.methods.multipart.ByteArrayPartSource;
public class updateRecords
{
public static void main(String a[])
{
try
{
//----------------------------Fetch Auth Token ----------------------
String authtoken = "6bb297a5cf5bc298eec9de2bf9f7690d";//If you don't have a authtoken please refer this wiki https://zohocrmapi.wiki.zoho.com/using-authtoken.html
String scope = "crmapi";
String recordId = "754788000000142035";
String newFormat = "1";
String targetURL = "https://crm.zoho.com/crm/private/xml/Leads/updateRecords";
String paramname = "content";
String xmlDataString = "<Leads><row no=\"1\"><FL val=\"Company\">Zoho</FL><FL val=\"First Name\">Scott</FL><FL val=\"Last Name\">James</FL><FL val=\"Annual Revenue\">11111.0</FL><FL val=\"Mobile\">999999999999</FL></row></Leads>";
PostMethod post = new PostMethod(targetURL);
post.setParameter("authtoken",authtoken);
post.setParameter("scope",scope);
post.setParameter("newFormat",newFormat);
post.setParameter("id",recordId);
post.setParameter("xmlData",xmlDataString);
HttpClient httpclient = new HttpClient();
PrintWriter myout = null;
// Execute http request
try
{
long t1 = System.currentTimeMillis();
int result = httpclient.executeMethod(post);
System.out.println("HTTP Response status code: " + result);
System.out.println(">> Time taken " + (System.currentTimeMillis() - t1));
// writing the response to a file
myout = new PrintWriter(new File("response.xml"));
myout.print(post.getResponseBodyAsString());
//------------Get response as a string ----------
String postResp = post.getResponseBodyAsString();
System.out.println("postResp=======>"+postResp);
}
catch(Exception e)
{
e.printStackTrace();
}
finally
{
myout.close();
post.releaseConnection();
}
}
catch(Exception e)
{
e.printStackTrace();
}
}
}