Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 46379

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

$
0
0

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


Viewing all articles
Browse latest Browse all 46379

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>