Rest store requires authorized user?

Vote:
 

Hi

Does rest stores require that the visitor is authorized?

I get this error when i'm anonymous:

[ArgumentNullException: Value cannot be null.
Parameter name: value]
   System.Web.HttpHeaderCollection.SetHeader(String name, String value, Boolean replace) +12512492
   EPiServer.Shell.Services.Rest.RestHttpHandler.ValidateAntiForgeryToken(HttpContextBase httpContext) +203
   EPiServer.Shell.Services.Rest.RestHttpHandler.ProcessRequest(HttpContextBase httpContext) +109
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +913
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +165

    

#72181
Jun 10, 2013 16:21
Vote:
 

Hello Jon,

 

I am getting this same error, did you manage to solve this issue?

 

Best Regards

#75114
Sep 18, 2013 9:05
Vote:
 

Looks like it, yes - CreateValidationToken() method below will return null if user is not authenticated.

httpContext.Response.Headers[aspNetAntiForgery.HeaderName] = aspNetAntiForgery.CreateValidationToken();

    

I would call this a bug.

#75157
Sep 18, 2013 18:58
Vote:
 

Hello Mari,

Thanks for your debugging help, I just registered an "incident". Will follow up in this thread as soon as I get a response back.

Cheers,

#75161
Sep 19, 2013 4:22
Vote:
 

Hello,

 

The response from the EPiServer Support Team:

"Unfortunately you can't use REST data anonymously and if you want to do that, you have to use WebAPI a standard thing from Microsoft."

 

ASP. NET Web API is pretty straightforward as well, specially if you are already developing a ASP. NET MVC site. If the site is based on WebForms, the following link would help:

http://www.asp.net/web-api/overview/creating-web-apis/using-web-api-with-aspnet-web-forms

 

If your responses need to be in JSON, one alternative would be the following:

http://stackoverflow.com/questions/9847564/how-do-i-get-asp-net-web-api-to-return-json-instead-of-xml-using-chrome

 

Regards,

 

 

#75195
Sep 20, 2013 4:28
Vote:
 

Hi,

I am working on EPiserver CMs 7 Rest service as per the article:http://world.episerver.com/Documentation/Items/Developers-Guide/EPiServer-Framework/7/User-Interface/Setting-Up-a-REST-Data-Store/ and http://bergdaniel.se/creating-a-rest-data-store-in-episerver-7-preview.

I am getting an error "value can not be null" when i am anonymous.

Server Error in '/' Application. Value cannot be null.
Parameter name: value Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ArgumentNullException: Value cannot be null.
Parameter name: value

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.


Stack Trace:

[ArgumentNullException: Value cannot be null.
Parameter name: value]
   System.Web.HttpHeaderCollection.SetHeader(String name, String value, Boolean replace) +9512466
   System.Web.HttpHeaderCollection.Set(String name, String value) +23
   EPiServer.Shell.Services.Rest.RestHttpHandler.ValidateAntiForgeryToken(HttpContextBase httpContext) +108
   EPiServer.Shell.Services.Rest.RestHttpHandler.ProcessRequest(HttpContextBase httpContext) +81
   EPiServer.Shell.Services.Rest.RestHttpHandler.ProcessRequest(HttpContext context) +42
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +341
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +69

Also when accessing the restservice with login the Json response starts with "{}&&" thus making the response data not getting validated.

Can anyone provide any inputs on how to access EPiserver rest service anonymously and how to parse the Json response starting with "{}&&".

Any help will be highly appreciated.

Thanks

Gunjan

Mob:+91-9831027164

#111693
Oct 17, 2014 14:35
Vote:
 

The EPiServer REST stores are to be used for user interface functions only and these require that you are authenticated. If you want to use this for the public site, we recommend that you use Web.API instead.

#111697
Oct 17, 2014 14:55
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.