open-formulieren / open-forms

Smart and dynamic forms
https://open-forms.readthedocs.io
Other
36 stars 26 forks source link

Service fetch: allow setting "expected_status" for status codes that are not 200 #3106

Open LaurensBurger opened 1 year ago

LaurensBurger commented 1 year ago

Thema / Theme

Form designer

Omschrijving / Description

As a form designer i want to set the "expected_status" for the response my service fetch request makes. At the moment this can only be 200, but POST requests typically return a 201.

alextreme commented 1 year ago

Discussed with Laurens:

https://github.com/open-formulieren/open-forms/blob/7d44b60888510509ce2c9aabfeff3cef245aa775/src/openforms/submissions/logic/service_fetching.py#L41

client.request(**request_args) should be given the parameter expected_status=201 in this situation. Unfortunately there isn't an option in zgw_consumers/zds_client to pass along multiple expected statusses (ideally you would want to accept all 2XX responses instead of only a fixed status code of 200).

A few options: