function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

issues with creating new objects

im trying to create a process where users can create new objects into their salesforce account from a crm site.  im trying to get the sample code below but can't get it to work. can someone please help me fix this or if im doing it totally wrong please let me know.

PostMethod m = new PostMethod(sfSession.getInstanceUrl() + "/services/data/v20.0/sobjects/Account/") {

            public String getName() {
                return "PATCH";

        m.setRequestHeader("Authorization", "OAuth " + sfSession.getAccessToken());

        Map<String, Object> accUpdate = new HashMap<String, Object>();
        accUpdate.put("Name", "Patch test");
        accUpdate.put("AnnualRevenue", 10);
        ObjectMapper mapper = new ObjectMapper();
        try {
            m.setRequestEntity(new StringRequestEntity(mapper.writeValueAsString(accUpdate), "application/json", "UTF-8"));
        } catch (UnsupportedEncodingException ex) {
            Logger.getLogger(Iprofile.class.getName()).log(Level.SEVERE, null, ex);

        HttpClient c = new HttpClient();
        int sc = c.executeMethod(m);
        System.out.println("PATCH call returned a status code of " + sc);



PATCH is used to update existing records, you need to use a regular POST if you want to create a new record.