While calling the REST API created by Data API Builder for my stored procedure:
https://localhost:5001/API/pagecustomers/pagesize/10/index/2
I received the error Primary key not configured on the given database object
. This is confusing because the stored procedure does not have a primary key. I am passing the proc parameters pagesize
and index
.
I am using this configuration:
"PageCustomers": {
"source": {
"type": "stored-procedure",
"object": "[dbo].[PageCustomers]",
"parameters": {
"PageSize": "",
"StartIndex": ""
}
},
"permissions": [
{
"role": "anonymous",
"actions": [
"execute"
]
}
],
"mappings": {
"Id": "Id",
"Name": "Name",
"City": "City",
"State": "State"
},
"rest": {
"path": "/pagecustomers",
"methods": [
"get"
]
},
"graphql": {
"operation": "mutation"
}
},
This error is the result of the structure of the url. Slash-separated parameters in the url specify the primary key value(s) of the database object. Instead, when calling stored procedures, parameters are specified in the querystring
.
https://localhost:5001/API/pagecustomers?pagesize=10&index=2
With this change, the REST call to the proc works fine.