diff --git a/src/plone/restapi/serializer/relationfield.py b/src/plone/restapi/serializer/relationfield.py index d54cadb9d..3115568d0 100644 --- a/src/plone/restapi/serializer/relationfield.py +++ b/src/plone/restapi/serializer/relationfield.py @@ -18,7 +18,7 @@ @implementer(IJsonCompatible) def relationvalue_converter(value): if value.to_object: - request = getRequest() + request = getRequest().clone() request.form["metadata_fields"] = ["UID"] summary = getMultiAdapter((value.to_object, request), ISerializeToJsonSummary)() return json_compatible(summary) diff --git a/src/plone/restapi/tests/test_dxfield_serializer.py b/src/plone/restapi/tests/test_dxfield_serializer.py index bac16ffcc..625ea83d5 100644 --- a/src/plone/restapi/tests/test_dxfield_serializer.py +++ b/src/plone/restapi/tests/test_dxfield_serializer.py @@ -325,6 +325,19 @@ def test_relationlist_field_serialization_returns_list(self): value, ) + def test_relation_field_serialization_do_not_change_request(self): + self.request.form["metadata_fields"] = ["foo", "bar"] + doc2 = self.portal[ + self.portal.invokeFactory( + "DXTestDocument", + id="doc2", + title="Referenceable Document", + description="Description 2", + ) + ] + self.serialize("test_relationchoice_field", doc2) + self.assertEqual(self.request.form["metadata_fields"], ["foo", "bar"]) + def test_remoteurl_field_in_links_get_converted(self): link = self.portal[ self.portal.invokeFactory(