0

Using the contact repository I am able to access historic interactions, but I would like to access the current interaction in the web API, I could access it through the MongoDB driver, but is it possible to access through a higher level of abstraction.

I'm on sitecore 8.2

1

The higher-level of abstraction, an API, was introduced in Sitecore 9 as 'xConnect'. If you upgrade to Sitecore 9, you can communicate with xDB via the xConnect layer and not need to work directly with the database anymore.

This does not exist in Sitecore 8.x.

Some resources

  • I would just like to access the interaction for a given contactID, and upgrading at this point is not currently an option. – Matthew Butler Sep 19 at 13:24
  • Understood, but your question was how to access these details with an API, and that is not available in Sitecore 8 out-of-the-box. You would need to build that layer, or upgrade. – Jason St-Cyr Sep 19 at 13:38
  • Yes, I assume I would have to build a layer, I was hoping there would be a higher level than the session or mongodb. My alternative is to make specific webapi routes have a session – Matthew Butler Sep 19 at 16:26
  • If you want to make an upgrade easier, you could look at the xConnect layer I suppose and try to make an 8.x version of it (not the full thing, just a similar communication mechanism/client API classes) so that an upgrade would be easier for you in the future – Jason St-Cyr Sep 19 at 16:54
0

Assuming you're trying to access the current interaction from an ASP.NET WebApi controller. You will need to do the following:

  1. Enable Session state for WebApi routes

  2. Call Tracker.StartTracking() explicitly

  3. Use Tracker.Current to access the current contact and interaction

You can then access your current interaction and contact data

if (!Tracker.IsActive)
{
    Tracker.StartTracking();
}

// Now access through Tracker.Current.Interaction
  • This won't work, as WebAPI does not use session. – Pete Navarra Oct 5 at 22:00
  • 1
    Enabling session state for some or all WebAPI routes is possible as described here: stackoverflow.com/questions/9594229/… I would consider only activating session state on a specific route and keeping all other WebAPI controllers session-less because there is a performance impact from managing sessions. – Mark Lowe Oct 6 at 13:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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