What happened?
I have an entity based on a stored procedure
"GetBusNearPosition": {
"source": {
"object": "dbo.GetBusNearPosition",
"type": "stored-procedure",
"parameters": {
"latitude": "0",
"longitude": "0",
"radius": 500
}
},
"permissions": [
{
"role": "anonymous",
"actions": [ "*" ]
}
],
}
and by default the entity is available, using REST, via POST at /api/GetBusNearPosition
If I add the rest object to configure the route:
"rest": {
"path": "/bus-near-position"
}
the default support for the POST verb is gone. If I try to call the endpoint:
POST http://localhost:5000/api/bus-near-position
I get a 405 error:
HTTP/1.1 405 Method Not Allowed
Connection: close
Content-Type: application/json; charset=utf-8
Date: Tue, 16 May 2023 21:37:14 GMT
Server: Kestrel
Transfer-Encoding: chunked
x-ms-correlation-id: 6b3db163-426f-454d-8eb1-79cb839d1078
{
"error": {
"code": "BadRequest",
"message": "This operation is not supported.",
"status": 405
}
}
In order to make everything working again I need to add the methods property to the rest object:
"rest": {
"methods": [ "post" ]
"path": "/bus-near-position"
}
With this everything works again.
It seems that the property methods is considered empty if there is a rest object that doesn't explicitly contain methods. The expectation is that, if no methods is present, the default, for a Stored Procedure, is post.
Tested both on 0.6.14 and 0.7.5
Version
Microsoft.DataApiBuilder 0.7.5+2f938a6dfe4b90c26d9e24352b38280cb6e66f15
What database are you using?
Azure SQL
What hosting model are you using?
Local (including CLI)
Which API approach are you accessing DAB through?
REST
Relevant log output
Microsoft.AspNetCore.Hosting.Diagnostics[1]
Request starting HTTP/1.1 POST http://localhost:5000/api/bus-near-position application/json 66
info: Microsoft.AspNetCore.Hosting.Diagnostics[2]
Request finished HTTP/1.1 POST http://localhost:5000/api/bus-near-position application/json 66 - 307 0 - 3.7979ms
info: Microsoft.AspNetCore.Hosting.Diagnostics[1]
Request starting HTTP/1.1 POST https://localhost:5001/api/bus-near-position application/json 66
dbug: Azure.DataApiBuilder.Service.AuthenticationHelpers.ClientRoleHeaderAuthenticationMiddleware[0]
3a72d9e5-e0f7-40d8-b5fe-a9af88d05387: Request authentication state: Anonymous.
dbug: Azure.DataApiBuilder.Service.AuthenticationHelpers.ClientRoleHeaderAuthenticationMiddleware[0]
3a72d9e5-e0f7-40d8-b5fe-a9af88d05387: The request will be executed in the context of Anonymous role
info: Microsoft.AspNetCore.Routing.EndpointMiddleware[0]
Executing endpoint 'Azure.DataApiBuilder.Service.Controllers.RestController.Insert (Azure.DataApiBuilder.Service)'
info: Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker[3]
Route matched with {action = "Insert", controller = "Rest"}. Executing controller action with signature System.Threading.Tasks.Task`1[Microsoft.AspNetCore.Mvc.IActionResult] Insert(System.String) on controller Azure.DataApiBuilder.Service.Controllers.RestController (Azure.DataApiBuilder.Service).
fail: Azure.DataApiBuilder.Service.Controllers.RestController[0]
3a72d9e5-e0f7-40d8-b5fe-a9af88d05387: This operation is not supported.
fail: Azure.DataApiBuilder.Service.Controllers.RestController[0]
3a72d9e5-e0f7-40d8-b5fe-a9af88d05387: at Azure.DataApiBuilder.Service.Services.RestService.ExecuteAsync(String entityName, Operation operationType, String primaryKeyRoute)
at Azure.DataApiBuilder.Service.Controllers.RestController.HandleOperation(String route, Operation operationType)
info: Microsoft.AspNetCore.Mvc.Infrastructure.SystemTextJsonResultExecutor[1]
Executing JsonResult, writing value of type '<>f__AnonymousType0`1[[<>f__AnonymousType1`3[[System.String, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.String, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.Int32, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], Azure.DataApiBuilder.Service, Version=0.7.5.0, Culture=neutral, PublicKeyToken=null]]'.
info: Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker[2]
Executed action Azure.DataApiBuilder.Service.Controllers.RestController.Insert (Azure.DataApiBuilder.Service) in 42.8858ms
info: Microsoft.AspNetCore.Routing.EndpointMiddleware[1]
Executed endpoint 'Azure.DataApiBuilder.Service.Controllers.RestController.Insert (Azure.DataApiBuilder.Service)'
info: Microsoft.AspNetCore.Hosting.Diagnostics[2]
Request finished HTTP/1.1 POST https://localhost:5001/api/bus-near-position application/json 66 - 405 - application/json;+charset=utf-8 82.6701ms
Code of Conduct
What happened?
I have an entity based on a stored procedure
and by default the entity is available, using REST, via POST at
/api/GetBusNearPositionIf I add the
restobject to configure the route:the default support for the POST verb is gone. If I try to call the endpoint:
I get a 405 error:
In order to make everything working again I need to add the
methodsproperty to therestobject:With this everything works again.
It seems that the property
methodsis considered empty if there is arestobject that doesn't explicitly containmethods. The expectation is that, if nomethodsis present, the default, for a Stored Procedure, ispost.Tested both on 0.6.14 and 0.7.5
Version
Microsoft.DataApiBuilder 0.7.5+2f938a6dfe4b90c26d9e24352b38280cb6e66f15
What database are you using?
Azure SQL
What hosting model are you using?
Local (including CLI)
Which API approach are you accessing DAB through?
REST
Relevant log output
Code of Conduct