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
Anil Kulkarni 67Anil Kulkarni 67 

How to Create Custom Object in Salesforce using REST API

Not able to create a Custom object using REST API. Below is the C# code.

                dynamic account = new ExpandoObject();
                account.Name = "Custom Object";
                account.Description = "New Salesforce Integration";

                string endpoint = instanceUrl + "/services/data/v36.0/sobjects/CustomObject__c";                

                using (var httpClient = new HttpClient())
                {
                    using (var httpRequest = new HttpRequestMessage(HttpMethod.Post, endpoint))
                    {
                        httpRequest.Headers.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);

                        httpRequest.Content = new StringContent(JsonConvert.SerializeObject(account), Encoding.UTF8, "application/json");
                        using (var httpResponse = await httpClient.SendAsync(httpRequest))
                        {
                            if (httpResponse.IsSuccessStatusCode)
                            {
                                var response = await httpResponse.Content.ReadAsStringAsync();
                                var result = serializer.Deserialize<Dictionary<string, object>>(response);                               
                            }

                            string errorResult = await httpResponse.Content.ReadAsStringAsync();
                            jsonObject = serializer.Deserialize<Dictionary<string, object>>(errorResult);                           
                        }
                    }
                }

I always get error result as  "Requested object not found", since there is no custom object created yet in salesforce.
I would like to know how to create Custom Object in Salesforce using REST API.
GarryPGarryP
You Cant create CUSTOM OBJECT uisng Force.com Rest API you will have to use Metadata API.
https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_intro.htm

with REST API you can just create Records and not metadata for object