You need to sign in to do that
Don't have an account?
Anil 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.
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.
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