web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Passing an Entity as a parameter to an Action in a Web API

(0) ShareShare
ReportReport
Posted on by 1,031

I would like to pass an Entity as the first parameter to an Action (mc_LeadUpsert) from a Web API so that we can update any number of attributes of the Lead. Here's the code (so far):


JObject lead = new JObject();
lead.Add("emailaddress2", emailAddress);
lead.Add("mc_institution@odata.bind", string.Format("/businessunits({0})", college));
lead.Add("firstname", firstName);
lead.Add("middlename", middleName);
lead.Add("lastname", lastName);
lead.Add("mc_areaofinterest", areaOfInterest);

if (campaignName == null || campaignName == "")
{
campaignName = "Default Campaign Name";
}

JObject leadUpsertParams = new JObject();

leadUpsertParams["Target"] = JObject.Parse(
@"{Lead: '" + JsonConvert.SerializeObject(lead) + "@odata.type': 'Microsoft.Dynamics.CRM.Lead', CampaigName: '" + campaignName + "', CreatePhoneCall: true}");

At this last line it errors saying {"After parsing a value an unexpected character was encountered: :. Path 'Lead', line 1, position 229."}

I do not see any examples showing exactly how to pass in an Entity. Does anyone have any suggestions?

thanks!
clint

*This post is locked for comments

I have the same question (0)

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans