+ Start a Discussion
Divya MallDivya Mall 

how to create a custom object like Employee and insert value into it using apex rest api

how to create a custom object like Employee and insert value into it using apex rest api
Raj VakatiRaj Vakati
I Can Split your question into the two parts 

1. Creating custom object Employee  ( You can able to do it by using STandard Setup or by using metadata )

2 . Data load 

You can able to load the data by using rest resource 

curl https://yourInstance.salesforce.com/services/data/v20.0/sobjects/<Cutsom_Obj__C>/ -H "Authorization: Bearer token -H "Content-Type: application/json" -d "@newaccount.json"

Narender Singh(Nads)Narender Singh(Nads)
Hi Divya,

You can create the Custom object record using Rest API via Workbench.

For workbench:
URL: /services/data/v42.0/sobjects/Employee__c
Method: POST
Body:Here assign the field values for all the required fields on that object. For example, say Name is the only required Field on that custom object then your body will look like
"Name":"Workbench Record"

Likewise you can map other field values.

Let me know if it helps.
Divya MallDivya Mall
Hi.. Narender Singh i am new in salesforce so that i want to know that how to strore and retrive our data from salesforce and for that i have gothrough the salesforce tutorial and found that i have to create custom object like Employee and it custom field like Id, Name, Address etc. so now how can I insert record into this using APEX Rest and retrive data from it. If you have any idea so plesae help me bro.. 
Narender Singh(Nads)Narender Singh(Nads)
I am having some trouble understanding your requirement.
Q. What do you mean by apex rest? A custom rest api existting in the org or the Standard rest api of salesforce. 
Q. From where are you trying to access the Rest API? From within the org(using Apex), or from workbench or from a 3rd party tool?
Divya MallDivya Mall
1. Apex is the salesforce programming language which is used for backed for creating a class,metho,property like OOPS and REST is use for create a restfull services to insert update and delete.
2. In my project there are seperate Dot Net development team and they want to use salesforce so that we need to create the APEX REST API 
Narender Singh(Nads)Narender Singh(Nads)
Ohhh, you want to create a custom rest api.

I am assuming that you have a decent knowledge about Apex.

Your custom rest api will look like this:
global with sharing class CustomRESTApi {

 //Function for POST method
  global static String createfunction(//PASS YOUR PARAMETERS IF ANY) {
     //YOUR Logic 
  global static String getfunction() {
     //YOUR Logic 
  global static String putfunction(//PASS YOUR PARAMETERS IF ANY) {
     //YOUR Logic 
//Likewise you can create a methods for PATCH and DELETE 


I would suggest using the standard Rest Api provided by salesforce unless you want some customized functionality.

Refer this link: https://developer.salesforce.com/page/Creating_REST_APIs_using_Apex_REST