-
-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
POST to a new table returns a 404, but GET on the same table returns a 200 #3231
Comments
Ah, for methods different than curl --location 'http://my.server/ApiVersion'
--header 'Content-Profile: pmg'
--header 'Content-Type: application/json'
--header 'Authorization: Bearer (token containing the db_admin role)
--data '[
{
"name": "weird-wallaby-93"
}
]' |
I should add that I went through all the reproduction steps above, but instead of using the |
@laurenceisla YES! That fixed it. But the weird thing is the other POST requests I have in Postman against tables in a different schema ('industrial'), worked with the Accept-Profile header, which is quite strange. Thank you so much! |
Two headers is always confusing, agree. We'll fix this on #2927. |
Does this behavior described by @jbstewart can be explained by something else than the schema selection in the header? I'm facing the exact same problem while following the tutorial. After creating the todos tables and applying the dedicated privileges I have a 200 OK with GET |
Things like that can always be explained by Schema Cache Reloading - or a lack thereof: https://postgrest.org/en/v12/references/schema_cache.html |
@wolfgangwalther thank you for the hint. So I will take care of schema reloading, and add the |
Environment
postgrest/postgrest
Description of issue
I added a table
ApiVersion
to mypmg
schema through a database migration. My problem is that when I try to POST a record in Postman to/ApiVersion
, I get a 404 with no error body. I have another request in Postman that is a GET/ApiVersion
and I get a 200 on that route.db_admin
has both USAGE and CREATE privileges on thepmg
schemadb_admin
and got:db_admin,pmg,ApiVersion,{db_admin=arwdDxt/db_admin}
So, the
db_admin
role has been granted INSERT, SELECT, UPDATE, DELETE, TRUNCATE, REFERENCES, and TRIGGER privileges on the table.db_admin,pmg,ApiVersion_id_seq,{db_admin=rwU/db_admin}
. So, thedb_admin
role has been granted SELECT, UPDATE, and USAGE privileges on the sequence.Summary
I would expect to be able to insert records in the
pmg."ApiVersion"
table with a POST request, but I get a 404. I can do a GET on the table with a 200.Steps to Reproduce
Table Creation
I create the table using a Knex migration, but the equivalent SQL (supplied by TablePlus) is below:
CREATE SEQUENCE IF NOT EXISTS pmg."ApiVersion_id_seq";
CREATE TABLE "pmg"."ApiVersion" (
"id" int4 NOT NULL DEFAULT nextval('pmg."ApiVersion_id_seq"'::regclass),
"name" varchar NOT NULL,
"activeDate" timestamptz NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY ("id")
);
Populate the table
SET ROLE db_admin;
INSERT INTO pmg."ApiVersion" ("name") VALUES ('weird-wallaby-92');
GET request
curl --location 'http://my.server/ApiVersion?order=id.desc&limit=1'
--header 'Accept-Profile: pmg'
--header 'Authorization: Bearer (token containing the db_admin role)
Result:
POST request
curl --location 'http://my.server/ApiVersion'
--header 'Accept-Profile: pmg'
--header 'Content-Type: application/json'
--header 'Authorization: Bearer (token containing the db_admin role)
--data '[
{
"name": "weird-wallaby-93"
}
]'
Result:
{}
The text was updated successfully, but these errors were encountered: