Cannot create Category by API - ActiveRecord::ValueTooLong

I’m trying to create a category by the API and am getting an Internal Server Error response. If I look in the Error Logs section I can see the following error repeatedly occur when I try to create the category:

ActiveRecord::ValueTooLong (PG::StringDataRightTruncation: ERROR: value too long for type character varying(6) ) /var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rack-mini-profiler-1.1.6/lib/patches/

Seems pretty obvious eh? Except my request is:

Method: POST, RequestUri: 'https://xxx/categories', Version: 1.1, Content: System.Net.Http.MultipartFormDataContent, Headers:
{
  Api-Key: xxx
  Api-Username: xxx
  Accept: application/json
  User-Agent: lb-legacy-content-migrator
  Content-Type: multipart/form-data; boundary="f86b1fe9-5a87-4794-b949-8c0fb1347cb5"
}:[
  {
    "Key": "name",
    "Value": "Features"
  },
  {
    "Key": "color",
    "Value": "#ee00da"
  },
  {
    "Key": "text_color",
    "Value": "#000000"
  },
  {
    "Key": "skip_validations",
    "Value": "true"
  }
]

I’ve tried omitting the skip_validations parameter but no change.
Am able to create other objects fine.

Any ideas what might be causing this?

إعجاب واحد (1)

Have you tried submitting the hex colors without the # in front? It’s squawking about a value being too long with the number 6 so that’s my impression without digging in further on the code side.

8 إعجابات

That did the job. It’s obvious now. Thanks :slight_smile:

3 إعجابات