0

How to Access the sitecore.Context from my custom web api to manage the Roles? I am trying to connect to sitecore context using custom APIs.

2
  • are you facing any issue in using Sitecore.Context in custom web api or facing issue in managing roles using Sitecore.Context in web api? Jan 6, 2022 at 11:55
  • Yes , It says Provider is missing, Have configured the web config and the sitecore kernel dlls. If you have any links orblog references please share. Jan 6, 2022 at 12:02

1 Answer 1

0

In one of my recent Sitecore project I had created a custom API by inheriting "System.Web.Http.ApiController". In this I used "Sitecore.Context" without any issue.

I was just calling this custom api using my Sitecore site hostname like https://local.sc.com/api/customapi

Please check this blog https://techsitecore.wordpress.com/2020/12/31/sitecore-secure-custom-api-in-sitecore/

This may help how to configure custom api.

6
  • But this is to secure the API and not to connect to the context Jan 6, 2022 at 14:12
  • That's why I said that this blog may help you to know how to configure custom api. I just created a custom api and used Sitecore.Context without any issue. Jan 6, 2022 at 15:12
  • Just look the process to "Create an API controller in Sitecore project" and "Register Routes" in that blog. Ignore "Authorization Handler" for now. Jan 6, 2022 at 15:13
  • After doing all steps mentioned in the blog, deploying the dlls into bin and config into the sitecore iis itemwebapi config folder, hitting the homeurl/get/{itemid} doesnt seem to work, Are pipelines required or am i missing some configuration? Jan 10, 2022 at 6:41
  • Can you please share the Route you had registered for this endpoint and the complete URL which you are hitting? If possible then please share api controller name and function name which you had created for this. Just want to ensure if you are hitting right url with right api and function. Jan 10, 2022 at 7:23

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