You need to sign in to do that
Don't have an account?
Mahesh KG
How to Create an Account in Salesforce using REST API
Can you please let me know how to create an Account in Salesforce using the REST API.
i also need to know where i can find my clientId and Client Secret to get the access token
i also need to know where i can find my clientId and Client Secret to get the access token
Hi Mahesh,
Please find the steps below to create an Account using REST API:
* Login to Workbench (https://workbench.developerforce.com/login.php).
* Navigate to 'Utilities -> REST Explorer'
* Select the 'Method' as 'POST'
* Paste the below line in the text box:
* Click on 'Headers' and paste the below:
* In the Request Body, paste the below content:
* Click 'Execute'. The Account will be created.Refer Trailhead (https://trailhead.salesforce.com/en/content/learn/modules/api_basics/api_basics_rest) module for more information about REST API.
Refer this link (https://stackoverflow.com/questions/12794302/salesforce-authentication-failing/29112224#29112224) for the steps to know your Client ID and Client Secret.
Please mark this answer as 'Best Answer' if this answers your question.
Best Regards.
* Create a Connected App (for Authentication). Reference. (https://trailhead.salesforce.com/content/learn/modules/connected-app-basics/learn-about-connected-apps)
* Create a REST service Apex Class in Salesforce, which gets the necessary parameters (like Name, Country etc.) for Account creation, as shown in the 'Create a Record with a POST Method' section here (https://trailhead.salesforce.com/en/content/learn/modules/apex_integration_services/apex_integration_webservices).
* Perform the callout using the Client ID and Client Secret you will get from the Connected App.
* Once the connection is established, call the REST Service class, which will create the record in Salesforce.
Please mark this answer as 'Best Answer' if this answers your question.
Best Regards.
i have below fields that we are using today on the salesforce for creating the order. Can you please let me know the corresponding objects that i need to pass them to my controller. i would like to know what is the object that i need to send to create the account in salesforce.
Please find the below list of fields highlighted.
i have below fields like AccountName,ParentAccount etc,. i need to know how i need to send them as the object to create the account and how the values should be sent to the dropdown?
Supply the required field values in the request data, and then use the POST method of the resource. The response body will contain the ID of the created record if the call is successful.
Example of creating a new Account
Method :- Post
URL:- /services/data/v36.0/sobjects/Account/
Example Request Body for creating an account:-
{ "Name" : "Express Logistics and Transport" }
Example response body after successfully creating a new Account
{ "id" : "0019000001hE8apAAC", "success" : true, "errors" : [ ] }
I suggest to visit these links, it will help you in understand how to create a record using API
https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_sobject_create.htm
https://www.youtube.com/watch?v=ry_j7tnx298
There is a specific Trailhead for this:-
https://trailhead.salesforce.com/en/content/learn/modules/api_basics/api_basics_soap?trail_id=force_com_dev_intermediate
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks and Regards,
Deepali Kulshrestha
www.kdeepali.com
Hi Mahesh,
Based on your screenshots, you want to create 'Account' object in Salesforce. The Object API name is 'Account' itself. You can pass the values to your REST Service method (refer my last comment). For dropdown values, you can pass as 'String' and assign them directly. If they are constants, then you can assign them in the REST Service class directly.
Please mark this answer as 'Best Answer' if this answers your question.
Best Regards.