Project

General

Profile

Bug #4180

Updated by Dominic Cleal over 8 years ago

Here's the request:

curl -k -u admin:changeme -H "Accept: version=2,application/json" -X POST \
-d "name=test&fullname=blah.test.com" http://localhost:3000/api/domains

Here's the response:

{"id":null,"errors":{"name":["can't be blank"]},"full_messages":["DNS domain can't be blank"]}

Here's the content-type:

:url_encoded_form

Here's the rails log:

<pre>
Started POST "/api/domains" for 127.0.0.1 at 2014-01-24 09:02:50 -0500
Processing by Api::V2::DomainsController#create as JSON
Parameters: {"name"=>"test", "fullname"=>"blah.test.com", "apiv"=>"v2"}
Setting Load (0.3ms) SELECT "settings".* FROM "settings" WHERE "settings"."name" = 'authorize_login_delegation' ORDER BY name LIMIT 1
Setting Load (0.3ms) SELECT "settings".* FROM "settings" WHERE "settings"."name" = 'signo_sso' ORDER BY name LIMIT 1
User Load (0.4ms) SELECT "users".* FROM "users" WHERE "users"."login" = 'admin' LIMIT 1
AuthSource Load (0.4ms) SELECT "auth_sources".* FROM "auth_sources" WHERE "auth_sources"."id" = 1 LIMIT 1
CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."login" = 'admin' LIMIT 1
Authenticated user Admin User against INTERNAL authentication source
User Load (0.7ms) SELECT "users".* FROM "users" WHERE "users"."login" = 'admin' ORDER BY firstname LIMIT 1
Setting current user thread-local variable to Admin User
(0.2ms) begin transaction
(7.2ms) UPDATE "users" SET "last_login_on" = '2014-01-24 14:03:32.041702', "updated_at" = '2014-01-24 14:03:32.058316', "preferences" = '--- {}
' WHERE "users"."id" = 1
(102.5ms) commit transaction
Role Load (0.3ms) SELECT "roles".* FROM "roles" WHERE "roles"."name" = 'Anonymous' LIMIT 1
(0.3ms) SELECT "roles".id FROM "roles" INNER JOIN "user_roles" ON "roles"."id" = "user_roles"."role_id" WHERE "user_roles"."user_id" = 1
CACHE (0.0ms) SELECT "roles".* FROM "roles" WHERE "roles"."name" = 'Anonymous' LIMIT 1
Role Exists (0.3ms) SELECT 1 AS one FROM "roles" INNER JOIN "user_roles" ON "roles"."id" = "user_roles"."role_id" WHERE "user_roles"."user_id" = 1 AND "roles"."id" = 8 LIMIT 1
Setting current user thread-local variable to Admin User
User Load (0.5ms) SELECT "users".* FROM "users" WHERE "users"."login" = 'admin' LIMIT 1
Authorized user admin(Admin User)
Setting current user thread-local variable to Admin User
Location Load (0.4ms) SELECT "taxonomies".* FROM "taxonomies" WHERE "taxonomies"."type" IN ('Location') AND "taxonomies"."id" IS NULL LIMIT 1
Setting current location thread-local variable to none
Organization Load (0.3ms) SELECT "taxonomies".* FROM "taxonomies" WHERE "taxonomies"."type" IN ('Organization') AND "taxonomies"."id" IS NULL LIMIT 1
Setting current organization thread-local variable to none
(0.2ms) begin transaction
Domain Exists (0.8ms) SELECT 1 AS one FROM "domains" WHERE "domains"."name" = '' LIMIT 1
(0.2ms) rollback transaction
Unprocessable entity Domain (id: new):
DNS domain can't be blank

Rendered api/v2/errors/unprocessable_entity.json.rabl (4.9ms)
Body: {"id":null,"errors":{"name":["can't be blank"]},"full_messages":["DNS domain can't be blank"]}
Completed 422 Unprocessable Entity in 4844.6ms (Views: 384.1ms | ActiveRecord: 120.5ms)
</pre>



This example comes from http://theforeman.org/manuals/1.4/index.html#5.1.1CRUDRequestExamples

I think we need to extend wrap_parameters to include :url_encoded_form and application/x-www-form-urlencoded.

Back