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
Amogh RaghuramAmogh Raghuram 

Salesforce rest API returns describe object instead of creating a new Lead

I am trying to create a new Lead but when I try out the API it returns 200 with describeObject instead of creating a lead and returning the ID

curl --location 'https://name-dev-ed.develop.lightning.force.com/services/data/v59.0/sobjects/Lead/' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer 00D5j00000DQ7Ba!AQgAQCIlBNxXsEyXIIsPNurfHWMq99TqQqtSvGOWm3JToc__idfks8WjMctEdoSHCzE1ZokJpO5whehqwc_' \
--header 'Cookie: BrowserId=ukmN3mQ5Ee6AQgllZPMmgw; CookieConsentPolicy=0:1; LSKey-c$CookieConsentPolicy=0:1' \
--data-raw '{
    "attributes": {
        "type": "Lead"
    },
    "Salutation": "Mr.",
    "FirstName": "Anon",
    "LastName": "Anon_lastname",
    "Email": "anon@gmail.com,
    "Phone": "1234",
    "Company": "CompanyA",
    "Title": "Engineer"
}
'
Best Answer chosen by Amogh Raghuram
Amogh RaghuramAmogh Raghuram
I figured out what the issue is. The domain URL should not be https://name-dev-ed.develop.lightning.force.com and should be https://name-dev-ed.develop.my.salesforce.com. 

All Answers

AshwiniAshwini (Salesforce Developers) 
Hi Amogh,
Can you try something like below:
curl --location 'https://name-dev-ed.develop.lightning.force.com/services/data/v59.0/sobjects/Lead/' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer 00D5j00000DQ7Ba!AQgAQCIlBNxXsEyXIIsPNurfHWMq99TqQqtSvGOWm3JToc__idfks8WjMctEdoSHCzE1ZokJpO5whehqwc_' \
--header 'Cookie: BrowserId=ukmN3mQ5Ee6AQgllZPMmgw; CookieConsentPolicy=0:1; LSKey-c$CookieConsentPolicy=0:1' \
--data-raw '{
    "Salutation": "Mr.",
    "FirstName": "Anon",
    "LastName": "Anon_lastname",
    "Email": "anon@gmail.com",
    "Phone": "1234",
    "Company": "CompanyA",
    "Title": "Engineer"
}'

If this information helps, please mark the answer as best. Thank you
Amogh RaghuramAmogh Raghuram
I removed the attributes key and tried again but it still doesn't work
AshwiniAshwini (Salesforce Developers) 
@Amogh,
In your payload, there's a missing double quote at the end of the email address:
Change: "Email": "anon@gmail.com,
To: "Email": "anon@gmail.com",

Thanks.
 
Amogh RaghuramAmogh Raghuram

Hi, this must've happened while copy pasting here. But in my postman I am sending the request with a valid JSON object and I am getting a successful response as well. The response is like this

{
"objectDescribe": {
"activateable": false,
"associateEntityType": null,
"associateParentEntity": null,
"createable": true,
"custom": false,
"customSetting": false,
"deepCloneable": false,
"deletable": true,
"deprecatedAndHidden": false,
"feedEnabled": true,
"hasSubtypes": false,
"isInterface": false,
"isSubtype": false,
"keyPrefix": "00Q",
"label": "Lead",
"labelPlural": "Leads",
"layoutable": true,
"mergeable": true,
"mruEnabled": true,
"name": "Lead",
"queryable": true,
"replicateable": true,
"retrieveable": true,
"searchable": true,
"triggerable": true,
"undeletable": true,
"updateable": true,
"urls": {
"compactLayouts": "/services/data/v59.0/sobjects/Lead/describe/compactLayouts",
"rowTemplate": "/services/data/v59.0/sobjects/Lead/{ID}",
"approvalLayouts": "/services/data/v59.0/sobjects/Lead/describe/approvalLayouts",
"listviews": "/services/data/v59.0/sobjects/Lead/listviews",
"describe": "/services/data/v59.0/sobjects/Lead/describe",
"quickActions": "/services/data/v59.0/sobjects/Lead/quickActions",
"layouts": "/services/data/v59.0/sobjects/Lead/describe/layouts",
"sobject": "/services/data/v59.0/sobjects/Lead"
}
},
"recentItems": [
{
"attributes": {
"type": "Lead",
"url": "/services/data/v59.0/sobjects/Lead/00Q5j00000U9kMTEAZ"
},
"Id": "00Q5j00000U9kMTEAZ",
"Name": "Anon"
},
{
"attributes": {
"type": "Lead",
"url": "/services/data/v59.0/sobjects/Lead/00Q5j00000ULmcqEAD"
},
"Id": "00Q5j00000ULmcqEAD",
"Name": "Feager, Patricia"
}
]

David Pease 5David Pease 5
I had a similar issue.  I was using POSTMAN to test Lead creation and mistakenly did not specifiy the "https://" portion of the URL.  Postman defaulted to "http://" and apparently the SF REST API will return a describe result when it receives a properly authorized request over http.  I'd double check that whatever platform is making your API call to Salesforce is using the correct "https://" protocol.
Amogh RaghuramAmogh Raghuram
I figured out what the issue is. The domain URL should not be https://name-dev-ed.develop.lightning.force.com and should be https://name-dev-ed.develop.my.salesforce.com. 
This was selected as the best answer