You need to sign in to do that
Don't have an account?
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"
}
'
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"
}
'
Apex Code Development
All Answers
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
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.
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"
}
]
}