Inhalte aufrufen

Profilbild

WebApi: Newly setup gives exception back "Value cannot be null."


  • Bitte melden Sie sich an, um eine Antwort zu verfassen.
1 Antwort zu diesem Thema

#1 TripleNico

TripleNico

    Advanced Member

  • Members
  • PunktPunktPunkt
  • 124 Beiträge

Geschrieben: 15 April 2020 - 11:08

So i changed the webapi endpoint from my sandbox comminuty SmartStore 3.2.2. to the live webapi endpoint Enterprise SmartStore 3.2.2. Gave one users the rights for WebApi, generated the keys, al went fine but know when i do a random request i get a respons back with exception "Value cannot be null."

 

The same error also occurs when i use the /Swagger Try it out!

 

Wireshark session:

GET /odata/v1/Orders()?$top=99999&$expand=BillingAddress,ShippingAddress,OrderItems,Customer HTTP/1.1
DataServiceVersion: 1.0;NetFx
MaxDataServiceVersion: 3.0;NetFx
Accept-Charset: UTF-8,UTF-8
User-Agent: Microsoft ADO.NET Data Services
Pragma: no-cache
Cache-Control: no-cache, no-store
Accept: application/json, text/javascript, */*
SmartStore-Net-Api-PublicKey: <PublicKey>
SmartStore-Net-Api-Date: 2020-04-15T10:00:39.2080942Z
Authorization: SmNetHmac1 64n<Hash>14=
Host: shop.somedomain.com
Connection: Keep-Alive

HTTP/1.1 500 Internal Server Error
Cache-Control: no-cache
Pragma: no-cache
Content-Type: application/json; charset=utf-8
Expires: -1
Server: Microsoft-IIS/10.0
DataServiceVersion: 3.0
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Wed, 15 Apr 2020 10:00:39 GMT
Content-Length: 2246

{
  "odata.error":{
    "code":"","message":{
      "lang":"en-US","value":"An error has occurred."
    },"innererror":{
      "message":"Value cannot be null.\r\nParameter name: name","type":"System.ArgumentNullException","stacktrace":"   at System.Security.Principal.GenericIdentity..ctor(String name, String type)\r\n   at SmartStore.Core.SmartStoreIdentity..ctor(Int32 customerId, String name, String type) in C:\\WebSites\\SmartStoreNET-3.2.2\\src\\Libraries\\SmartStore.Core\\Security\\SmartStorePrincipal.cs:line 14\r\n   at SmartStore.Core.SmartStorePrincipal..ctor(Customer customer, String type) in C:\\WebSites\\SmartStoreNET-3.2.2\\src\\Libraries\\SmartStore.Core\\Security\\SmartStorePrincipal.cs:line 29\r\n   at SmartStore.Web.Framework.WebApi.Security.WebApiAuthenticateAttribute.OnAuthorization(HttpActionContext actionContext) in C:\\WebSites\\SmartStoreNET-3.2.2\\src\\Presentation\\SmartStore.Web.Framework\\WebApi\\Security\\WebApiAuthenticateAttribute.cs:line 232\r\n   at System.Web.Http.Filters.AuthorizationFilterAttribute.OnAuthorizationAsync(HttpActionContext actionContext, CancellationToken cancellationToken)\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Filters.AuthorizationFilterAttribute.<ExecuteAuthorizationFilterAsyncCore>d__3.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Filters.AuthorizationFilterAttribute.<ExecuteAuthorizationFilterAsyncCore>d__3.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__15.MoveNext()"
    }
  }
}

The web api settings are:

Angehängte Bilder



#2 TripleNico

TripleNico

    Advanced Member

  • Members
  • PunktPunktPunkt
  • 124 Beiträge

Geschrieben: 15 April 2020 - 13:01

Figured it out. The username of the used user was nothing. Changing this to a value, like the customer email addres, solved the problem.