Hot answers tagged

13

This should actually now work out of the box on a clean 8.2 install. Among the resolved issues from the 8.2 release notes: ​Sitecore.Services.Client prevents using Attribute Routing with ASP.NET WebAPI​. Sitecore is calling the config.MapHttpAttributeRoutes() from Sitecore.Services.Client in the initialize pipeline. This is the one throwing the error ...


12

Web API is apparently really aggressive when it caches API Controller types. I was able to fix my issue by doing the following: stop IIS kill the w3wps navigate to C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root and obliterate anything in this folder Make sure the registration of the route happens after processor[@type='...


10

You have most of the pieces you need, but not all. You need a patch config <configuration xmlns:patch="http://www.sitecore.net/xmlconfig/"> <sitecore> <initialize> <processor patch:before="processor[@type='Sitecore.Mvc.Pipelines.Loader.InitializeRoutes, Sitecore.Mvc']" type="...


9

Utilizing data extension points The first thing I would consider is whether your data can be stored as part of the standard Sitecore entities. Contact The xDB contact has the following fields where you can store custom data that will be saved to MongoDB: Facets Attachments Tags Interactions CustomValues If you use any of the above, you won't have to ...


8

There are a number of approaches people have taken to accomplish such a task. One of my preferences is to use the Sitecore PowerShell Extensions (SPE) module. With some knowledge of PowerShell, you can just about do anything with the content. Option 1 : Sitecore Item Web API Use whatever method available to you, such as the Item Web API. With SPE or ...


8

You can implement custom DelegatingHandler base on Sitecore.Services behavior: using System.Linq; using System.Net.Http; using System.Security.Claims; using System.Threading; using System.Threading.Tasks; using Sitecore.Services.Core.Security; using Sitecore.Services.Infrastructure.Sitecore.Security; using Sitecore.Services.Infrastructure.Web.Http.Security; ...


7

The issue is where you're initializing the Web API DependencyResolver in the Sitecore initialize pipeline. In Sitecore 8.2, the part of the initialize pipeline where the MVC and Web API DependencyResolvers need to be registered is as follows: Sitecore 8.2 Initialize Pipeline <sitecore> <pipelines> <initialize> ... <...


6

You can use Sitecore Client Services to expose data from Sitecore Sitecore.Services.Client provides a service layer on both the server and the client side of Sitecore applications that you use to develop data-driven applications. Sitecore.Services.Client is configurable and extendable, and the framework and scaffolding it provides help you create the ...


5

I think you need to move the stuff in your WebApiApplication.Application_Start method to the initialize pipeline like you are doing with the RegisterRoutes class. In Sitecore 8.2 (or somewhere around there) they made Application_Start internal so you can't override it anymore. I've been told this has been marked as a bug at Sitecore and I supposed it will ...


5

Here is a low complexity example using Sitecore PowerShell Extensions. Make sure that the SPE Remoting Module files are saved to a path configured in $env:PSModulePath. Save script to desired path: Import-Module -Name SPE $session = New-ScriptSession -Username "admin" -Password "b" -ConnectionUri "http://remotesitecore/" Invoke-RemoteScript -ScriptBlock { ...


5

The issue may be related to your other question where it appears that you have some invalid date formats. From the StackTrace it looks like the issue is related to one of the Media facets. I would try disabling the 'Date uploaded' facet under /sitecore/client/Applications/Dialogs/SelectMediaDialog/PageSettings/Facets from the Core database to see if that ...


5

https://sdn.sitecore.net/Products/Sitecore%20Item%20Web%20API/SitecoreItemWebApi12.aspx Sitecore Item Web API 1.2. This version of the module only runs on Sitecore CMS 6.6.0 rev. 131211 (6.6.0 Update-7) and later. It seems you will need to install it as a module (it was not included in the product - that happened in 7.1).


5

It was moved to SPEAK routes in Sitecore 9 and unavailable on CD server. You can resolve it by adding this snippet to your routing configuration (if you really need this API route - best practice is to create your own routes for your API calls): if (ConfigurationManager.AppSettings["role:define"] == "ContentDelivery") { RouteTable.Routes.MapRoute("...


4

One option is to enable Sitecore.Speak.Mvc.Config file . In the Sitecore.Speak.Mvc.config file, the InitializeCommandRoute processor maps the /api/sitecore/{controller}/{action} route for SPEAK UI Applications, which are used by Sitecore Content Management installation. Probably your ajax call are using /api/sitecore. If there is not a specific reason ...


4

Ran into this exact same issue but with Ninject instead. From what I could tell it was a conflict of resolution between WebAPI and MVC. Ultimately I was able to resolve the issue by implementing my own IDependencyResolver and IDependencyScope and binding that in the App_Start (suggested in https://stackoverflow.com/questions/20595472/mvc5-web-api-2-and-...


4

The built-in Sitecore scheduler can certainly be frustrating in its limitations. So using a WebApi endpoint that the task can call is certainly one way of doing things. You should keep security in mind though; if your URL can easily be guessed and doesn't require authentication then anonymous users can potentially trigger it. You should definitely ...


4

Sitecore security model does provide API for determining user access rights (see Sitecore.Security.AccessControl.ItemAccess class). AFAIK there is no any web service exposing it but you can easily create one using Sitecore Services Client: public class AccessController : ServicesApiController { [Route("sitecore/api/ssc/itemaccess/{database}/{itemId}")] ...


4

The /sitecore/api route is a default route added by Sitecore in configs that are specific to the content management aspects of the platform. These configs are not enabled for content delivery. As noted in x3mxray's answer, they can be reenabled, but I wouldn't recommend it. Instead of reenabling the default routes for other functionality you (probably) don't ...


3

An easy option would be to create your own webapi controller and create an action that does the publish, using the Sitecore API: Sitecore.Publishing.PublishManager.PublishItem(...) You can pass the item id as a parameter and fetch it from the master database. Other options for the Publish function can be parameterized as well, depending on how flexible you ...


3

Sitecore PowerShell Extensions - Web API As pointed out by Richard, SPE comes with some ways to do this. You can find more details about the latest version of SPE Remoting here. For now we will stick the Web API option which will give you a url similar to that in your example. Here are some steps to get you going: Install SPE 4.3+. Enable the Web API ...


3

There isn't anything OOTB that will allow you to hit a rest service. You have a couple of options: Sitecore PowerShell Extensions You could use Sitecore PowerShell Extensions remoting to do that fairly easily. Syntax to serialize an item is: serialize-item -path "master:\content" If you want children included, then: get-childitem "master:\...


3

If the WEB Api returns the same order as items sorted in the content tree you can change it by: Select an item folder where all sub-items required to be sorted by some criteria. On the Home Ribbon click "Sorting" and change sort order to created. Before: Result:


3

It's possible to extend although not entirely that easy because Sitecore uses a lot of dynamics instead of actually typing things when it comes to ItemWebApi. A small example (note that this kinda works but isn't intended to actually be used, more like a starting point): public class SortResult : ReadProcessor { #region Overrides of ...


3

There should be nothing related to debug mode, can you please check it again? If still same problem do below settings: Make a Log for security related stuffs or other variables in a processor before/after below processor just to check what your request is doing. <processor type="Sitecore.ItemWebApi.Pipelines.HttpRequest.CheckMode, Sitecore.ItemWebApi" ...


3

So I had an issue with this custom Web API hosted inside my Sitecore solution, that will be used by a third party to call upon some Authentication and Authorization functionality. I did the following things to make it work: I mistakenly named my API as ApiController which is actually a built-in Abstract class, so changed it to CustomerAPIController Removed ...


3

Could you please try the following solution? Add the following after line 10 in advanced-sample-react\src\dataProvider\DataProvider.prod.js: params.sc_site = 'jssadvancedapp'; For context: const getFetchOptions = (language, options = {}) => { const params = options.params || {}; params.sc_site = 'jssadvancedapp'; ... this forces the site ...


3

It needs to create custom routing for calling a controller action method for multisite. Steps are as below: Step 1) Add App_start folder in the Foundation Layer Project. Add a class file in this folder e.g. RegisterWebApiRoutes.cs, use the below code in this class file. public void Process(PipelineArgs args) { RouteTable.Routes.MapRoute(...


3

MapRoute is meant for MVC controllers whereas MapHttpRoute is meant for Web API controllers. ServiceApiController is ApiController, and you should register your route with MapHttpRoute instead of MapRoute. Just register your route with: GlobalConfiguration.Configure(config => { config.Routes.MapHttpRoute("botroutes", "api/messages", new { ...


2

By enabling CORS you are enabling Cross Origin Resource Sharing. You would need to supply the domains that would be allowed to call your endpoint. As you are not making a call from an external domain, but from within an App, your request will be cancelled even before any method has been executed, as it's not allowed: https://www.asp.net/web-api/overview/...


2

I think since you have a DI configured that will be resetting any routes registered after you've added them so you need to do this afterwards in the initialize Pipeline like so: Create a pipeline to register your route: public class RegisterMySampleRoute { public virtual void Process(PipelineArgs args) { RouteTable.Routes.MapHttpRoute("...


Only top voted, non community-wiki answers of a minimum length are eligible