You need to sign in to do that
Don't have an account?
Arshad Shaikh
Rest Api error 400
This Rest api Java code authenticate to insert lead is working in my dev org But when I try to do the same in production it throws error 400 Can anybody sort it out.
static final String USERNAME = "arshadsdeveloper@gmail.com.dev"; static final String PASSWORD = "************************"; static final String LOGINURL = "https://login.salesforce.com"; static final String GRANTSERVICE = "/services/oauth2/token?grant_type=password"; static final String CLIENTID = "************************"; static final String CLIENTSECRET = "************************"; private static String REST_ENDPOINT = "/services/data"; private static String API_VERSION = "/v35.0"; private static String baseUri; private static Header oauthHeader; private static Header prettyPrintHeader = new BasicHeader("X-PrettyPrint", "1"); private static String leadId ; private static String leadFirstName; private static String leadLastName; private static String leadCompany; public static void main(String[] args) { HttpClient httpclient = HttpClientBuilder.create().build(); // Assemble the login request URL String loginURL = LOGINURL + GRANTSERVICE + "&client_id=" + CLIENTID + "&client_secret=" + CLIENTSECRET + "&username=" + USERNAME + "&password=" + PASSWORD; // Login requests must be POSTs HttpPost httpPost = new HttpPost(loginURL); HttpResponse response = null; try { // Execute the login POST request response = httpclient.execute(httpPost); } catch (ClientProtocolException cpException) { cpException.printStackTrace(); } catch (IOException ioException) { ioException.printStackTrace(); } // verify response is HTTP OK final int statusCode = response.getStatusLine().getStatusCode(); if (statusCode != HttpStatus.SC_OK) { System.out.println("Error authenticating to Force.com: "+statusCode); // Error is in EntityUtils.toString(response.getEntity()) return; }Any help Appreciated.
pcon
If you get the message / body from the request, do you get any additional information. It's likely tht your missing information or passing in the incorrect information.