8

I am trying to use the MS supplied BasicDataOperations provider hosted app to play around with and learn about remote event receivers.

I was following the instructions from this blog post by Chris O'Brien to deploy the app to a SharePoint Online site, and deploy the remote event receiver web to an Azure website. I've also set up an Azure Service Bus to do the redirection to my computer so I can debug the code.

When I try to debug, everything starts up normally, the app gets deployed to the SharePoint site, and when I add a list item through the app, my breakpoint gets hit. However, I am also getting a GetContextTokenError. The error message is:

The endpoint address 'https://my-servicebus-namespace.servicebus.windows.net/DL-TAG365/dcristy/obj/4fd86c25-6149-4455-adc6-fb3f20cfcb04/RemoteEventReceiver1.svc' does not match the app's endpoint 'my-azure-site.azurewebsites.net'.

I'm not sure where to go to specify/change the app's endpoint. Is that happening because I registered the app on AppRegNew.aspx using the Azure site URL?

My app manifest looks like this:

  <Properties>
    <Title>BasicDataOperations</Title>
    <StartPage>https://my-azure-site.azurewebsites.net/Pages/Default.aspx?{StandardTokens}</StartPage>
    <!--<StartPage>~appWebUrl/Lists/List1</StartPage>-->
    <InstalledEventEndpoint>~remoteAppUrl/AppEventReceiver.svc</InstalledEventEndpoint>
  </Properties>

and as far as I'm aware, using the ~remoteAppUrl token in the event endpoint is what's somehow connecting the events through the service bus back to my computer. That's also what I'm using in the event receiver declaration:

  <Receivers ListTemplateId="100">
      <Receiver>
        <Name>RemoteEventReceiver1ItemAdding</Name>
        <Type>ItemAdding</Type>
        <SequenceNumber>10000</SequenceNumber>
        <Url>~remoteAppUrl/RemoteEventReceiver1.svc</Url>
      </Receiver>
  </Receivers>

And I'm not even worried about the AppEventReceiever.svc right now, I just want to get everything working with the RemoteEventReceiver1.svc. Without the token, the BasicDataOperations code doesn't run (they check for a valid context token before doing anything), and even if I wrote some code that would run, I'm sure I probably need that context token for something, right?

So how do I set it up so that I get a valid context token while debugging?

3
  • Did you make the debug work? Just got the same issue here and would like to know before hunting a solution. Commented Jan 21, 2016 at 13:58
  • Luciano, I did not get it working. It was just playing around learning, not related to any specific project, so when something more urgent came along I abandoned it. Commented Jan 21, 2016 at 14:47
  • Thanks Dylan. So, I will be investigating a solution form now. Commented Jan 21, 2016 at 16:01

2 Answers 2

1

In your AppManifest.xml

It should be like this:

<Properties>
    <Title>BasicDataOperations</Title>
    <StartPage>https://my-azure-site.azurewebsites.net/Pages/Default.aspx?{StandardTokens}</StartPage>
    <!--<StartPage>~appWebUrl/Lists/List1</StartPage>-->
    <InstalledEventEndpoint>https://my-azure-site.azurewebsites.net/Services/AppEventReceiver.svc</InstalledEventEndpoint>
  </Properties>

And your Remote Event Receiver's Element.xml should be like this:

<Receivers ListTemplateId="100">
      <Receiver>
        <Name>RemoteEventReceiver1ItemAdding</Name>
        <Type>ItemAdding</Type>
        <SequenceNumber>10000</SequenceNumber>
        <Url>https://my-azure-site.azurewebsites.net/Services/RemoteEventReceiver1.svc</Url>
      </Receiver>
  </Receivers>
1
  • 2
    ~remoteAppUrl is automatically replaced by Visual Studio at deployment, so there is no need to hard-code it. Commented Jun 10, 2015 at 16:21
0

I had faced the same issue and resolved it by updating ClientId as * in AppMenifest.xml file. Please try this if anyone facing the issue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.