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
Alex DrewAlex Drew 

API Integration Lead Creation Problem

Hi
I am working with our dev team to get an API set up to create leads in our Salesforce. The Authentication is fine and the API can access our Salesforce. The error returns when we try to create the Lead. The fields mapped are all correct with the API names etc so struggling to see where the issue is.
The USER set up has access to Leads and create them.
Any recommendations on what I might have missed would be great!
Thanks
Best Answer chosen by Alex Drew
Shashi PatowaryShashi Patowary
Hi Alex,
That is your org id, it should not be set as recordtype id. Recordtypeid starts with 012 (e.g. 01230000000N9Z1AAK). It is different for each object.You can log in to SFDC and go to Setup -->Lead-->RecordTypes to view all Lead record types.Then click on the any of the record type (or the specific one you want to set). In the browser URL you will see that id (starting with 012). Please set that id in the lead creation request. It should work.Alternately, you can query recordtype in SFDC -
SELECT Id,IsActive,SobjectType FROM RecordType where SobjectType='Lead' and IsActive = true

Please let me know if this is helpful.

Regards,
Shashi
 

All Answers

Shashi PatowaryShashi Patowary
Hi Alex,

Can you please post the error description. I will see if I can help you.

Regards,
Shashi
Alex DrewAlex Drew
Thanks Shashi, the error we are getting is "400 - Bad Request".
Shashi PatowaryShashi Patowary
Thanks Alex,

Probably the data that you are sending is not correct.Can you send the request body or the Lead fields data.

Regards,
Shashi
Alex DrewAlex Drew
Hi Shashi

We are posting to the fields below with the data being submitted per fields.

{"FirstName":"test",
"LastName":"test",
"Email":"test@test.net",
"Region_Location__c":
"United Kingdom",
"Brand__c":"Insight Vacations",
"Web_Request_Type__c":"Request a rochure",
"LeadSource":"Web",
"Selling_Company_Code__c":"IVUKLS",
"RecordTypeId":"00DJ000000374F3"}

Record tyype is Org ID for our SANDBOX we are posting this too.

All fields are mapped correctly, API names matching etc.
Thanks
Alex
Shashi PatowaryShashi Patowary
Hi Alex,
That is your org id, it should not be set as recordtype id. Recordtypeid starts with 012 (e.g. 01230000000N9Z1AAK). It is different for each object.You can log in to SFDC and go to Setup -->Lead-->RecordTypes to view all Lead record types.Then click on the any of the record type (or the specific one you want to set). In the browser URL you will see that id (starting with 012). Please set that id in the lead creation request. It should work.Alternately, you can query recordtype in SFDC -
SELECT Id,IsActive,SobjectType FROM RecordType where SobjectType='Lead' and IsActive = true

Please let me know if this is helpful.

Regards,
Shashi
 
This was selected as the best answer