i have use below code but get an error...
TypeError: Converting circular structure to JSON" on JavaScript
Code:
// Create a variable to point to a contact record and with specific data in the needed fields
var leadData = {
“@odata.type”: “Microsoft.Dynamics.CRM.lead”,
“firstname”: “Mike”,
“lastname”: “Staurt”,
“subject”:”Interested in Car”,
“telephone1″:”+973426536”
}
async function GetResult(leadData) {
var result = await (await fetch(‘/api/data/v9.2/new_addlead’, {
method: ‘POST’, // *GET, POST, PUT, DELETE, etc.
cache: ‘no-cache’, // *default, no-cache, reload, force-cache, only-if-cached
headers: {
‘Content-Type’: ‘application/json’
},
referrerPolicy: ‘no-referrer’, // no-referrer, *no-referrer-when-downgrade, origin, origin-when-cross-origin, same-origin, strict-origin, strict-origin-when-cross-origin, unsafe-url
body: JSON.stringify({ “lead”:leadData}) // body data type must match “Content-Type” header
})).json();
console.log(result.message);
return result.message;
}