ApiLogicServer
ApiLogicServer copied to clipboard
SqlServer NORTHWND fails to add Category using Admin App
Here is the log:
ValidationError: Invalid type member: Categorie != Category
Traceback (most recent call last):
File "/Users/val/dev/safrs/safrs/safrs_api.py", line 653, in method_wrapper
result = fun(*args, **kwargs)
File "/Users/val/dev/safrs/safrs/jsonapi.py", line 427, in post
instance = self._create_instance(data)
File "/Users/val/dev/safrs/safrs/jsonapi.py", line 452, in _create_instance
raise ValidationError(f"Invalid type member: {obj_type} != {self.SAFRSObject._s_type}")
safrs.errors.ValidationError
Validation Error: Invalid type member: Categorie != Category
127.0.0.1 - - [02/Mar/2022 18:52:49] "POST /api/Categories HTTP/1.1" 400 -
It does work with Swagger; cURL:
curl -X POST "http://localhost:5656/api/Categories/" -H "accept: application/vnd.api+json" -H "Content-Type: application/json" -d "{ \"data\": { \"attributes\": { \"CategoryName\": \"test\" }, \"type\": \"Category\" }}"
Same error occurring on MySQL/Sakalia - Categories
ValidationError: Invalid type member: Categorie != Category
Traceback (most recent call last):
File "/Users/val/dev/safrs/safrs/safrs_api.py", line 653, in method_wrapper
result = fun(*args, **kwargs)
File "/Users/val/dev/safrs/safrs/jsonapi.py", line 427, in post
instance = self._create_instance(data)
File "/Users/val/dev/safrs/safrs/jsonapi.py", line 452, in _create_instance
raise ValidationError(f"Invalid type member: {obj_type} != {self.SAFRSObject._s_type}")
safrs.errors.ValidationError
Validation Error: Invalid type member: Categorie != Category
127.0.0.1 - - [02/Mar/2022 18:52:49] "POST /api/Categories HTTP/1.1" 400 -
The "type" being sent must match the collection type. I don't know why your code posts "Categorie" instead of "Category".
The type defaults to the classname, it can be overriden if you'd wish to change it.
This is using the Admin app
On Sun, Mar 6, 2022 at 9:33 AM Thomas Pollet @.***> wrote:
The "type" being sent must match the collection type. I don't know why your code posts "Categorie" instead of "Category".
The type defaults to the classname, it can be overriden if you'd wish to change it.
— Reply to this email directly, view it on GitHub https://github.com/valhuber/ApiLogicServer/issues/41#issuecomment-1060006170, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABKSG35YAW3E2XVXM4KU43TU6TT6FANCNFSM5PZGTN2A . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
You are receiving this because you authored the thread.Message ID: @.***>
-- Thanks, Val
510-703-5909 valhuber on skype
Here is the project
sqlserver.zip
There is no "type" attribute in the admin.yaml. Compare with the resource "type" in https://apilogicserver.pythonanywhere.com/admin-app/index.html#/Configuration
Hmm: here is the admin, I am seeing type, no?
resources:
Categories:
attributes:
- label: ' Category Name*'
name: CategoryName
required: true
search: true
sort: true
- name: Description
- name: CategoryID
tab_groups:
- direction: tomany
fks:
- CategoryID
name: ProductList
resource: Products
type: Category
user_key: CategoryName
Maybe the problem is that table-name <> class-name. I am presuming it works like this.
This is the Jan 28 version, btw.