Internal server error setting tags via the api

We are getting below error while posting creating topic using API. sometimes its working but most of the time is shows below error.

Started POST "/posts.json?api_key=[FILTERED]&username=saroj.barad&title=Test%20%20From%20saroj&category=7&raw=Test%20%20From%20saroj&tags%5B%5D=law&tags%5B%5D=randomnewtag" for 127.0.0.1 at 2018-10-22 06:31:44 +0000

Processing by PostsController#create as JSON

Parameters: {"api_key"=>"[FILTERED]", "username"=>"saroj.barad", "title"=>"Test From saroj", "category"=>"7", "raw"=>"Test From saroj", "tags"=>["law", "randomnewtag"]}

Can't verify CSRF token authenticity.

Completed 500 Internal Server Error in 124ms (ActiveRecord: 8.8ms)

NoMethodError (undefined method `>' for nil:NilClass)

/var/www/discourse/lib/discourse_tagging.rb:58:in `tag_topic_by_names'

Started POST "/posts.json" for 127.0.0.1 at 2018-10-22 06:32:27 +0000

Processing by PostsController#create as JSON

Parameters: {"title"=>"Test from saroj", "category"=>"7", "tags"=>["finance"], "api_key"=>"[FILTERED]", "api_username"=>"saroj.barad", "raw"=>"Test from saroj "}

Completed 500 Internal Server Error in 200ms (ActiveRecord: 8.0ms)

NoMethodError (undefined method `>' for nil:NilClass)

See:

Attempt to change tags on a topic, looks at the param.

does discourse need X-CSRF-TOKEN?
if we pass “api key”. bcz we are sending api key in our request still it shows "Can’t verify CSRF token authentiity".

That error is not related.

Thanks for your replies. But we are also getting 500 error code while creating topic from discourse portal.

Started POST "/posts" for 127.0.0.1 at 2018-10-22 10:08:19 +0000
Processing by PostsController#create as JSON
Processing by Presence::PresencesController#publish as */*
Parameters: {"previous"=>""}
Parameters: {"raw"=>"Good post", "title"=>"How does the Membership functionality work", "unlist_topic"=>"false", "category"=>"7", "is_warning"=>"false", "archetype"=>"regular", "typing_duration_msecs"=>"6200", "composer_open_duration_msecs"=>"179956", "shared_draft"=>"false", "nested_post"=>"true"}
Completed 200 OK in 10ms (Views: 0.2ms | ActiveRecord: 3.0ms)
Completed 500 Internal Server Error in 59ms (ActiveRecord: 9.6ms)
NoMethodError (undefined method `>' for nil:NilClass)
/var/www/discourse/lib/topic_creator.rb:161:in `setup_tags'

Please help me with this.

Hi @Akki9326, it looks like we have a bug here. To work around it for now, open up the preferences for the category, and set the “Minimum number of tags required in a topic” setting to zero.

We will look at getting this fixed so it can’t happen in the future.

4 Likes

Thank @david for your reply. but there is no settings like 'Minimum number of tags required in a topic".

for your info:

  1. we are able to create a topic in other categories but error occurs on one specific category only named “CFO-Members”. we are able to create same topic in other categories.
  2. Admin can create topic in that category (CFO-Members).

it would be greate for us if can you suggest any work around for the same.

The setting is located in the “settings” tab for each specific category (the same place that you edit the category name).

4 Likes

Thanks @david its works. :slight_smile:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.

For future reference, this is now fixed thanks to @maja

https://github.com/discourse/discourse/commit/4a8f21d38743a0a6b2a161889e335581248583b9

4 Likes