From dc99a6a79ddeb4c142f4b2baae8a12c5a09083c9 Mon Sep 17 00:00:00 2001 From: Viktor van Wijk Date: Fri, 20 Dec 2024 17:10:04 +0100 Subject: [PATCH] :construction: [#4908] Add api response to submission registration result --- src/openforms/registrations/contrib/json/plugin.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/openforms/registrations/contrib/json/plugin.py b/src/openforms/registrations/contrib/json/plugin.py index b4bc902667..a90e5ac946 100644 --- a/src/openforms/registrations/contrib/json/plugin.py +++ b/src/openforms/registrations/contrib/json/plugin.py @@ -17,7 +17,7 @@ class JSONRegistration(BasePlugin): verbose_name = _("JSON registration") configuration_options = JSONOptionsSerializer - def register_submission(self, submission: Submission, options: JSONOptions) -> None: + def register_submission(self, submission: Submission, options: JSONOptions) -> dict: values = {} # Encode (base64) and add attachments to values dict if their form keys were specified in the # form variables list @@ -44,22 +44,19 @@ def register_submission(self, submission: Submission, options: JSONOptions) -> N } ) - print(values) - # Send to the service json = {"values": values} service = options["service"] + submission.registration_result = result = {} with build_client(service) as client: - response = client.post( + result["api_response"] = res = client.post( options.get("relative_api_endpoint", ""), json=json, headers={"Content-Type": "application/json"}, ) - response.raise_for_status() - print(response.json()) + res.raise_for_status() - # TODO-4908: added return for testing purposes - return json + return result def check_config(self): # TODO-4908: check if it's possible to connect to the service