Hello!
I've been messing around with the discourse api and I'm running into issues using it. I managed to setup discourse on my machine with the specs running correctly. When I try to to an invite a user to a topic using the api, it returns invalid access. Can someone take a look at my cURL and see if they can see what's wrong?
curl --data "email=admin@mailinator.com&topic_id=1&api_key=f8a279f3febc97c20e423e44aa0c7ae57797ee3f13f97e051735443fc2dbd633&api_username=eviltrout" http://localhost:3000/t/1/invite.json
It returns [error: 'invalid access']%
.
The server log looks like this:
Started POST "/t/1/invite.json" for 127.0.0.1 at 2014-02-11 21:04:34 -0800
Processing by TopicsController#invite as JSON
Parameters: {"email"=>"admin@mailinator.com", "topic_id"=>"1", "api_key"=>"f8a279f3febc97c20e423e44aa0c7ae57797ee3f13f97e051735443fc2dbd633", "api_username"=>"eviltrout"}
Can't verify CSRF token authenticity
ApiKey Load (1.4ms) SELECT "api_keys".* FROM "api_keys" WHERE "api_keys"."key" = 'f8a279f3febc97c20e423e44aa0c7ae57797ee3f13f97e051735443fc2dbd633' ORDER BY "api_keys"."id" ASC LIMIT 1
User Load (1.4ms) SELECT "users".* FROM "users" WHERE "users"."id" IN (24)
(1.3ms) SELECT "groups"."name" FROM "groups"
(1.7ms) SELECT categories.id FROM "categories" WHERE "categories"."read_restricted" = 't'
Category Load (1.6ms) SELECT "categories".* FROM "categories" WHERE (NOT categories.read_restricted or categories.id in (13)) ORDER BY "categories"."position" ASC
Topic Load (1.6ms) SELECT id, title, slug FROM "topics" WHERE ("topics"."deleted_at" IS NULL) AND "topics"."id" IN (10, 11, 12, 13, 41, 42, 43, 44, 45, 46, 47, 56, 55)
(1.4ms) SELECT "categories"."id" FROM "categories"
PostActionType Load (1.3ms) SELECT "post_action_types".* FROM "post_action_types" ORDER BY position asc
SiteContent Load (1.5ms) SELECT content FROM "site_contents" WHERE "site_contents"."content_type" = 'top' ORDER BY "site_contents"."content_type" ASC LIMIT 1
SiteContent Load (1.4ms) SELECT content FROM "site_contents" WHERE "site_contents"."content_type" = 'bottom' ORDER BY "site_contents"."content_type" ASC LIMIT 1
(1.2ms) SELECT COUNT(*) AS count_all, notification_type AS notification_type FROM "notifications" WHERE "notifications"."user_id" = $1 AND (id > 0 and read = false) GROUP BY notification_type [["user_id", 24]]
(1.1ms) SELECT COUNT(*) FROM "notifications" WHERE "notifications"."user_id" = $1 AND (read = false AND notification_type = 6) [["user_id", 24]]
UserStat Load (1.2ms) SELECT "user_stats".* FROM "user_stats" WHERE "user_stats"."user_id" = $1 ORDER BY "user_stats"."user_id" ASC LIMIT 1 [["user_id", 24]]
(1.1ms) SELECT COUNT(*) FROM "topics" WHERE ("topics"."deleted_at" IS NULL) AND "topics"."user_id" = $1 [["user_id", 24]]
(4.1ms) SELECT u.id AS user_id, topics.id AS topic_id, topics.created_at, highest_post_number, last_read_post_number, c.name AS category_name
FROM users u
FULL OUTER JOIN topics ON 1=1
LEFT JOIN topic_users tu ON tu.topic_id = topics.id AND tu.user_id = u.id
LEFT JOIN categories c ON c.id = topics.category_id
WHERE u.id IN (24) AND
topics.archetype <> 'private_message' AND
((tu.last_read_post_number < topics.highest_post_number AND COALESCE(tu.notification_level, 1) >= 2) OR (topics.created_at >= CASE
WHEN COALESCE(u.new_topic_duration_minutes, 2880) = -1 THEN u.created_at
WHEN COALESCE(u.new_topic_duration_minutes, 2880) = -2 THEN COALESCE(u.previous_visit_at,u.created_at)
ELSE ('2014-02-12 05:04:34.520719'::timestamp - INTERVAL '1 MINUTE' * COALESCE(u.new_topic_duration_minutes, 2880))
END AND tu.last_read_post_number IS NULL AND COALESCE(tu.notification_level, 2) >= 2)) AND
(topics.visible OR u.admin OR u.moderator) AND
topics.deleted_at IS NULL AND
( category_id IS NULL OR NOT c.read_restricted OR category_id IN (
SELECT c2.id FROM categories c2
JOIN category_groups cg ON cg.category_id = c2.id
JOIN group_users gu ON gu.user_id = u.id AND cg.group_id = gu.group_id
WHERE c2.read_restricted )
)
ApiKey Exists (1.7ms) SELECT 1 AS one FROM "api_keys" WHERE "api_keys"."key" = 'f8a279f3febc97c20e423e44aa0c7ae57797ee3f13f97e051735443fc2dbd633' LIMIT 1
Topic Load (1.9ms) SELECT "topics".* FROM "topics" WHERE ("topics"."deleted_at" IS NULL) AND "topics"."id" = 1 ORDER BY "topics"."id" ASC LIMIT 1
Rendered text template (0.0ms)
Completed 403 Forbidden in 52ms (Views: 0.5ms | ActiveRecord: 26.8ms)