Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

adapt content type on errors definition

ulferts50b1ac7a3dac
diff --git a/lib/api/root.rb b/lib/api/root.rb
index 66f5067b387..fe64cde5e91 100644
--- a/lib/api/root.rb
+++ b/lib/api/root.rb
@@ -35,7 +35,7 @@ module API
parser :json, API::V3::Parser.new
- error_representer ::API::V3::Errors::ErrorRepresenter, "hal+json"
+ error_representer ::API::V3::Errors::ErrorRepresenter, "application/hal+json; charset=utf-8"
authentication_scope OpenProject::Authentication::Scope::API_V3
OpenProject::Authentication.handle_failure(scope: API_V3) do |warden, _opts|
diff --git a/lib/api/utilities/grape_helper.rb b/lib/api/utilities/grape_helper.rb
index e2c37f8e7cb..270e6227eb3 100644
--- a/lib/api/utilities/grape_helper.rb
+++ b/lib/api/utilities/grape_helper.rb
@@ -71,7 +71,7 @@ module API
original_exception = $!
representer = error_representer.new e
resp_headers = instance_exec &headers
- env["api.format"] = error_content_type
+ resp_headers["Content-Type"] = error_content_type
if log == true
OpenProject.logger.error original_exception, reference: :APIv3
diff --git a/modules/bim/app/controllers/bim/bcf/api/root.rb b/modules/bim/app/controllers/bim/bcf/api/root.rb
index aac9d5a7f13..3fdcadc37d9 100644
--- a/modules/bim/app/controllers/bim/bcf/api/root.rb
+++ b/modules/bim/app/controllers/bim/bcf/api/root.rb
@@ -38,7 +38,7 @@ module Bim::Bcf
default_format :json
- error_representer ::Bim::Bcf::API::V2_1::Errors::ErrorRepresenter, :json
+ error_representer ::Bim::Bcf::API::V2_1::Errors::ErrorRepresenter, "application/json; charset=utf-8"
error_formatter :json, ::Bim::Bcf::API::ErrorFormatter::Json
authentication_scope OpenProject::Authentication::Scope::BCF_V2_1