I send the following ODATA message:
_DELETE http://localhost:34852/Tags(guid'43e361ba-a8a0-4dbe-8474-dfcb5496c161') HTTP/1.1__
DataServiceVersion: 3.0
MaxDataServiceVersion: 3.0
Host: localhost:34852
I get back an error:
HTTP/1.1 400 Bad Request
Cache-Control: no-cache
Pragma: no-cache
Content-Type: application/json; odata=minimalmetadata; streaming=true; charset=utf-8
Expires: -1
Server: Microsoft-IIS/8.0
DataServiceVersion: 3.0
X-AspNet-Version: 4.0.30319
X-SourceFiles: =?UTF-8?B?QzpcY3BtU291cmNlc1xLbm93bGVkZ2UgTWFuYWdlclxEZXZlbG9wbWVudFxEYXRhU2VydmljZVByb3RvdHlwZVxXZWJBcGlEYXRhU2VydmljZVxQaW1zQ29uZmlnRGF0YVN2Y1xBQkIuUElNUy5TZXJ2ZXIuQ29uZmlnU2VydmljZVxUYWdzKGd1aWQnNDNlMzYxYmEtYThhMC00ZGJlLTg0NzQtZGZjYjU0OTZjMTYxJyk=?=
X-Powered-By: ASP.NET
Date: Tue, 05 Mar 2013 11:36:20 GMT
Content-Length: 561
{
"odata.error":{
"code":"","message":{
"lang":"en-US","value":"The request is invalid."
},"innererror":{
"message":"The parameters dictionary contains a null entry for parameter 'key' of non-nullable type 'System.Guid' for method 'Void Delete(System.Guid)' in 'ABB.PIMS.Server.ConfigService.Controllers.Base.StoreEntitySetController`2[ABB.PIMS.Data.Model.Domain.RTDB.Tag,System.Guid]'. An optional parameter must be a reference type, a nullable type, or be declared as an optional parameter.","type":"","stacktrace":""
}
}
}
The error happens before any of the(standard and custom) routing conventions are evaluated.
GetByKey works correctly.
I use the released version of WebApi OData (v4.0.30319). See attachment for relevant trace log part.
Comments: Not sure if we are talking about the same thing. As you can see in initial comment, i try to perform a delete action. So if do override Delete method of class and not Get method. This is the method I override public override void Delete(Guid key) { ... } But code flow never reaches the Delete method, because OData WebApi framework does not handle correctly a Guid prefixed by guid' (which is the "official" ODATA format for Guid's as per ODATA spec). As I wrote in 1st post the GetByKey works as expected.
_DELETE http://localhost:34852/Tags(guid'43e361ba-a8a0-4dbe-8474-dfcb5496c161') HTTP/1.1__
DataServiceVersion: 3.0
MaxDataServiceVersion: 3.0
Host: localhost:34852
I get back an error:
HTTP/1.1 400 Bad Request
Cache-Control: no-cache
Pragma: no-cache
Content-Type: application/json; odata=minimalmetadata; streaming=true; charset=utf-8
Expires: -1
Server: Microsoft-IIS/8.0
DataServiceVersion: 3.0
X-AspNet-Version: 4.0.30319
X-SourceFiles: =?UTF-8?B?QzpcY3BtU291cmNlc1xLbm93bGVkZ2UgTWFuYWdlclxEZXZlbG9wbWVudFxEYXRhU2VydmljZVByb3RvdHlwZVxXZWJBcGlEYXRhU2VydmljZVxQaW1zQ29uZmlnRGF0YVN2Y1xBQkIuUElNUy5TZXJ2ZXIuQ29uZmlnU2VydmljZVxUYWdzKGd1aWQnNDNlMzYxYmEtYThhMC00ZGJlLTg0NzQtZGZjYjU0OTZjMTYxJyk=?=
X-Powered-By: ASP.NET
Date: Tue, 05 Mar 2013 11:36:20 GMT
Content-Length: 561
{
"odata.error":{
"code":"","message":{
"lang":"en-US","value":"The request is invalid."
},"innererror":{
"message":"The parameters dictionary contains a null entry for parameter 'key' of non-nullable type 'System.Guid' for method 'Void Delete(System.Guid)' in 'ABB.PIMS.Server.ConfigService.Controllers.Base.StoreEntitySetController`2[ABB.PIMS.Data.Model.Domain.RTDB.Tag,System.Guid]'. An optional parameter must be a reference type, a nullable type, or be declared as an optional parameter.","type":"","stacktrace":""
}
}
}
The error happens before any of the(standard and custom) routing conventions are evaluated.
GetByKey works correctly.
I use the released version of WebApi OData (v4.0.30319). See attachment for relevant trace log part.
Comments: Not sure if we are talking about the same thing. As you can see in initial comment, i try to perform a delete action. So if do override Delete method of class and not Get method. This is the method I override public override void Delete(Guid key) { ... } But code flow never reaches the Delete method, because OData WebApi framework does not handle correctly a Guid prefixed by guid' (which is the "official" ODATA format for Guid's as per ODATA spec). As I wrote in 1st post the GetByKey works as expected.