Retreiving Campaign Response Contact Information RRS feed

  • Question

  • Hi,

    I have a function which uses the 2016 Web API to return a list of attendees (campaign responses) from a particular event (Campaign). The code below works fine for very basic Campaign Responses where they are not regarding an existing contact, but what I want to be able to do is to retrieve the details of the contact or lead if they are associated instead. Does anyone know if this is possible to achieve in one API call? Or the most efficient way of going about this?any help would be greatly appreciated,


    public async Task<List<Attendee>> GetAttendees(string EventId)
                JObject collection;
                HttpResponseMessage response;
                string queryOptions;
                string[] getProperties = { "activityid", "firstname", "lastname", "companyname", "emailaddress", "responsecode" };
                string filter = @"&$filter=_regardingobjectid_value eq " + EventId;
                queryOptions = "?$select=" + String.Join(",", getProperties) + filter;
                response = await SendCrmRequestAsync(HttpMethod.Get, "campaignresponses" + queryOptions, true);
                if (response.StatusCode == HttpStatusCode.OK) //200
                    List<Attendee> Res = new List<Attendee>();
                    collection = JsonConvert.DeserializeObject<JObject>(response.Content.ReadAsStringAsync().Result);
                    JToken valArray;
                    if (collection.TryGetValue("value", out valArray))
                        foreach (JObject entity in (JArray)valArray)
                            Attendee na = new Attendee();
                            na.Id = entity["activityid"].ToString();
                            na.First = entity["firstname"].ToString();
                            na.Last = entity["lastname"].ToString();
                            na.Company = entity["companyname"].ToString();
                            na.Email = entity["emailaddress"].ToString();
                    return Res;
                { throw new CrmHttpResponseException(response.Content); }

    Monday, April 3, 2017 10:38 PM