Forum Discussion
Andreas Shakallis
Jun 09, 2017Copper Contributor
Need help with Remote Event Receiver / Debugging with Azure Bus Service
Hi everyone!
I'm trying to add a simple event receiver for a Contacts list.
I added the event receiver for on Item being added.
Here is my simple code :
using System; using System.Collections.Generic; using System.Linq; using System.Text; using Microsoft.SharePoint.Client; using Microsoft.SharePoint.Client.EventReceivers; namespace LeaveRequestWeb.Services { public class RemoteEventReceiver1 : IRemoteEventService { /// <summary> /// Handles events that occur before an action occurs, such as when a user adds or deletes a list item. /// </summary> /// <param name="properties">Holds information about the remote event.</param> /// <returns>Holds information returned from the remote event.</returns> public SPRemoteEventResult ProcessEvent(SPRemoteEventProperties properties) { SPRemoteEventResult result = new SPRemoteEventResult(); using (ClientContext clientContext = TokenHelper.CreateRemoteEventReceiverClientContext(properties)) { if (clientContext != null) { clientContext.Load(clientContext.Web); clientContext.ExecuteQuery(); } } return result; } /// <summary> /// Handles events that occur after an action occurs, such as after a user adds an item to a list or deletes an item from a list. /// </summary> /// <param name="properties">Holds information about the remote event.</param> public void ProcessOneWayEvent(SPRemoteEventProperties properties) { string firstName = Convert.ToString(properties.ItemEventProperties.AfterProperties["FirstName"]); int listItemId = properties.ItemEventProperties.ListItemId; Guid listId = properties.ItemEventProperties.ListId; using (ClientContext clientContext = TokenHelper.CreateRemoteEventReceiverClientContext(properties)) { if (clientContext != null) { try { Web web = clientContext.Web; List list = web.Lists.GetById(listId); ListItem item = list.GetItemById(listItemId); clientContext.Load(clientContext.Web); clientContext.ExecuteQuery(); item["FirstNamePhonetic"] = "olan Phonetic"; item.Update(); clientContext.ExecuteQuery(); } catch (Exception oops) { System.Diagnostics.Trace.WriteLine(oops.Message); } } } } } }
I'm just updating the value of FirstNamePhonetic but nothing happens.
Also even though i added the connection string of my azure namespace , i can't seem to manage it to debug ! I have tried everything but still get tthis message :
Cannot register Services/RemoteEventReceiver1.svc on Microsoft Azure Service Bus: The remote server returned an error: (500) Internal Server Error.
Any ideas how to fix these two issues?
Thanks a lot !
- DeletedI think you would get a faster help on the Azure forum rather than here. or even in SO.