HTTP Client DELETE with body
Saturday, 12 June 2021 · 7 messages
ML
Marco Lettere12 Jun 2021 11:47 #
Dear all,
I have to call an API which model an HTTP DELETE operation based on the body of the request.
It looks like currently
http:send-request is not allowing body to be present ("Body not expected for method DELETE.").
I feel that this is bit too restrictive interpretation of the spec which states (as far as I recall) that there is no defined semantic for the operation but not that it is forbidden.
Is there any possibility to relax this behaviour and allow for bodies in DELETE calls? [1]
Thank you very much.
Marco.
[1]
https://github.com/BaseXdb/basex/blob/382c8097afb1ec5bac1e9511a2287686c33f669d/basex-core/src/main/java/org/basex/util/http/HttpRequestParser.javaCG
Christian Grün12 Jun 2021 14:01 #
Hi Marco,
The error is basically raised because that's required by the spec [1].
But it's right that the RFC2616 doesn't explicitly forbid DELETE requests with bodies, so we could possibly get rid of the check.
So I guess you’ve stumbled upon an API that expects a payload with DELETE?
Cheers
Christian
[1] http://expath.org/spec/http-client#d2e104
Quoted text · Marco Lettere · 26 lines
Marco Lettere <m.lettere at gmail.com> schrieb am Sa., 12. Juni 2021, 11:48: > Dear all, > > I have to call an API which model an HTTP DELETE operation based on the > body of the request. > > It looks like currently http:send-request is not allowing body to be > present ("Body not expected for method DELETE."). > > I feel that this is bit too restrictive interpretation of the spec which > states (as far as I recall) that there is no defined semantic for the > operation but not that it is forbidden. > > Is there any possibility to relax this behaviour and allow for bodies in > DELETE calls? [1] > > Thank you very much. > > Marco. > > > [1] > > https://github.com/BaseXdb/basex/blob/382c8097afb1ec5bac1e9511a2287686c33f669d/basex-core/src/main/java/org/basex/util/http/HttpRequestParser.java > >
ML
Marco Lettere12 Jun 2021 15:14 #
Quoted text · Christian Grün · 2 lines
> So I guess you’ve stumbled upon an API that expects a payload with DELETE? >
Yes Christian, trying to delete an application role association to a user on the Keycloak REST APIs requires the role to be passed as JSON object in the DELETE body [1].
So at the moment I'm able to add roles to a user but I cannot change them because I'm unabale to remove one.
Telling just because you asked ;-)
Thanks a lot anyway for your attention.
[1]
https://www.keycloak.org/docs-api/11.0/rest-api/index.html#_client_role_mappings_resource
Quoted text · Christian Grün · 39 lines
> Cheers > Christian > > [1] http://expath.org/spec/http-client#d2e104 > <http://expath.org/spec/http-client#d2e104> > > > > > Marco Lettere <m.lettere at gmail.com <mailto:m.lettere at gmail.com>> > schrieb am Sa., 12. Juni 2021, 11:48: > > Dear all, > > I have to call an API which model an HTTP DELETE operation based > on the > body of the request. > > It looks like currently http:send-request is not allowing body to be > present ("Body not expected for method DELETE."). > > I feel that this is bit too restrictive interpretation of the spec > which > states (as far as I recall) that there is no defined semantic for the > operation but not that it is forbidden. > > Is there any possibility to relax this behaviour and allow for > bodies in > DELETE calls? [1] > > Thank you very much. > > Marco. > > > [1] > https://github.com/BaseXdb/basex/blob/382c8097afb1ec5bac1e9511a2287686c33f669d/basex-core/src/main/java/org/basex/util/http/HttpRequestParser.java > <https://github.com/BaseXdb/basex/blob/382c8097afb1ec5bac1e9511a2287686c33f669d/basex-core/src/main/java/org/basex/util/http/HttpRequestParser.java> >
CG
Christian Grün12 Jun 2021 16:37 #
Grazie, Marco.
You convinced me there is no benefit in keeping the restriction (and it we didn’t add it to the draft of version 2 of the spec either [1]). I’ve just uploaded a new snapshot [2]; I hope it keeps you going.
Ciao, Christian.
[1] https://expath.github.io/expath-cg/specs/http-client-2/
[2] https://files.basex.org/releases/latest/
Quoted text · Marco Lettere · 45 lines
> So I guess you’ve stumbled upon an API that expects a payload with DELETE? > > Yes Christian, trying to delete an application role association to a user on the Keycloak REST APIs requires the role to be passed as JSON object in the DELETE body [1]. > > So at the moment I'm able to add roles to a user but I cannot change them because I'm unabale to remove one. > > Telling just because you asked ;-) > > Thanks a lot anyway for your attention. > > [1] https://www.keycloak.org/docs-api/11.0/rest-api/index.html#_client_role_mappings_resource > > Cheers > Christian > > [1] http://expath.org/spec/http-client#d2e104 > > > > > Marco Lettere <m.lettere at gmail.com> schrieb am Sa., 12. Juni 2021, 11:48: >> >> Dear all, >> >> I have to call an API which model an HTTP DELETE operation based on the >> body of the request. >> >> It looks like currently http:send-request is not allowing body to be >> present ("Body not expected for method DELETE."). >> >> I feel that this is bit too restrictive interpretation of the spec which >> states (as far as I recall) that there is no defined semantic for the >> operation but not that it is forbidden. >> >> Is there any possibility to relax this behaviour and allow for bodies in >> DELETE calls? [1] >> >> Thank you very much. >> >> Marco. >> >> >> [1] >> https://github.com/BaseXdb/basex/blob/382c8097afb1ec5bac1e9511a2287686c33f669d/basex-core/src/main/java/org/basex/util/http/HttpRequestParser.java >>
ML
Marco Lettere12 Jun 2021 16:44 #
Thank you! I didn't want to disturb your weekend though.... Top quality BaseX service! 😁🤩
Il sab 12 giu 2021, 16:37 Christian Grün <christian.gruen at gmail.com> ha scritto:
Quoted text · Christian Grün · 65 lines
> Grazie, Marco. > > You convinced me there is no benefit in keeping the restriction (and > it we didn’t add it to the draft of version 2 of the spec either [1]). > I’ve just uploaded a new snapshot [2]; I hope it keeps you going. > > Ciao, Christian. > > [1] https://expath.github.io/expath-cg/specs/http-client-2/ > [2] https://files.basex.org/releases/latest/ > > > > So I guess you’ve stumbled upon an API that expects a payload with > DELETE? > > > > Yes Christian, trying to delete an application role association to a > user on the Keycloak REST APIs requires the role to be passed as JSON > object in the DELETE body [1]. > > > > So at the moment I'm able to add roles to a user but I cannot change > them because I'm unabale to remove one. > > > > Telling just because you asked ;-) > > > > Thanks a lot anyway for your attention. > > > > [1] > https://www.keycloak.org/docs-api/11.0/rest-api/index.html#_client_role_mappings_resource > > > > Cheers > > Christian > > > > [1] http://expath.org/spec/http-client#d2e104 > > > > > > > > > > Marco Lettere <m.lettere at gmail.com> schrieb am Sa., 12. Juni 2021, > 11:48: > >> > >> Dear all, > >> > >> I have to call an API which model an HTTP DELETE operation based on the > >> body of the request. > >> > >> It looks like currently http:send-request is not allowing body to be > >> present ("Body not expected for method DELETE."). > >> > >> I feel that this is bit too restrictive interpretation of the spec which > >> states (as far as I recall) that there is no defined semantic for the > >> operation but not that it is forbidden. > >> > >> Is there any possibility to relax this behaviour and allow for bodies in > >> DELETE calls? [1] > >> > >> Thank you very much. > >> > >> Marco. > >> > >> > >> [1] > >> > https://github.com/BaseXdb/basex/blob/382c8097afb1ec5bac1e9511a2287686c33f669d/basex-core/src/main/java/org/basex/util/http/HttpRequestParser.java > >> >
HR
Hans-Juergen Rennau12 Jun 2021 16:55 #
Indeed - common sense & top flexibility!
Am Samstag, 12. Juni 2021, 16:45:05 MESZ hat Marco Lettere <m.lettere at gmail.com> Folgendes geschrieben:
Thank you! I didn't want to disturb your weekend though.... Top quality BaseX service! 😁🤩
Quoted text · Christian Grün · 1 line
Il sab 12 giu 2021, 16:37 Christian Grün <christian.gruen at gmail.com> ha scritto:
Grazie, Marco.
You convinced me there is no benefit in keeping the restriction (and it we didn’t add it to the draft of version 2 of the spec either [1]). I’ve just uploaded a new snapshot [2]; I hope it keeps you going.
Ciao, Christian.
[1] https://expath.github.io/expath-cg/specs/http-client-2/
[2] https://files.basex.org/releases/latest/
Quoted text · Marco Lettere · 45 lines
> So I guess you’ve stumbled upon an API that expects a payload with DELETE? > > Yes Christian, trying to delete an application role association to a user on the Keycloak REST APIs requires the role to be passed as JSON object in the DELETE body [1]. > > So at the moment I'm able to add roles to a user but I cannot change them because I'm unabale to remove one. > > Telling just because you asked ;-) > > Thanks a lot anyway for your attention. > > [1] https://www.keycloak.org/docs-api/11.0/rest-api/index.html#_client_role_mappings_resource > > Cheers > Christian > > [1] http://expath.org/spec/http-client#d2e104 > > > > > Marco Lettere <m.lettere at gmail.com> schrieb am Sa., 12. Juni 2021, 11:48: >> >> Dear all, >> >> I have to call an API which model an HTTP DELETE operation based on the >> body of the request. >> >> It looks like currently http:send-request is not allowing body to be >> present ("Body not expected for method DELETE."). >> >> I feel that this is bit too restrictive interpretation of the spec which >> states (as far as I recall) that there is no defined semantic for the >> operation but not that it is forbidden. >> >> Is there any possibility to relax this behaviour and allow for bodies in >> DELETE calls? [1] >> >> Thank you very much. >> >> Marco. >> >> >> [1] >> https://github.com/BaseXdb/basex/blob/382c8097afb1ec5bac1e9511a2287686c33f669d/basex-core/src/main/java/org/basex/util/http/HttpRequestParser.java >>
CG
Christian Grün12 Jun 2021 17:07 #
…and exceptional kudos! ありがとう.
Quoted text · Hans-Juergen Rennau · 79 lines
Hans-Juergen Rennau <hrennau at yahoo.de> schrieb am Sa., 12. Juni 2021, 16:56: > Indeed - common sense & top flexibility! > > Am Samstag, 12. Juni 2021, 16:45:05 MESZ hat Marco Lettere < > m.lettere at gmail.com> Folgendes geschrieben: > > > Thank you! I didn't want to disturb your weekend though.... Top quality > BaseX service! 😁🤩 > > Il sab 12 giu 2021, 16:37 Christian Grün <christian.gruen at gmail.com> ha > scritto: > > Grazie, Marco. > > You convinced me there is no benefit in keeping the restriction (and > it we didn’t add it to the draft of version 2 of the spec either [1]). > I’ve just uploaded a new snapshot [2]; I hope it keeps you going. > > Ciao, Christian. > > [1] https://expath.github.io/expath-cg/specs/http-client-2/ > [2] https://files.basex.org/releases/latest/ > > > > So I guess you’ve stumbled upon an API that expects a payload with > DELETE? > > > > Yes Christian, trying to delete an application role association to a > user on the Keycloak REST APIs requires the role to be passed as JSON > object in the DELETE body [1]. > > > > So at the moment I'm able to add roles to a user but I cannot change > them because I'm unabale to remove one. > > > > Telling just because you asked ;-) > > > > Thanks a lot anyway for your attention. > > > > [1] > https://www.keycloak.org/docs-api/11.0/rest-api/index.html#_client_role_mappings_resource > > > > Cheers > > Christian > > > > [1] http://expath.org/spec/http-client#d2e104 > > > > > > > > > > Marco Lettere <m.lettere at gmail.com> schrieb am Sa., 12. Juni 2021, > 11:48: > >> > >> Dear all, > >> > >> I have to call an API which model an HTTP DELETE operation based on the > >> body of the request. > >> > >> It looks like currently http:send-request is not allowing body to be > >> present ("Body not expected for method DELETE."). > >> > >> I feel that this is bit too restrictive interpretation of the spec which > >> states (as far as I recall) that there is no defined semantic for the > >> operation but not that it is forbidden. > >> > >> Is there any possibility to relax this behaviour and allow for bodies in > >> DELETE calls? [1] > >> > >> Thank you very much. > >> > >> Marco. > >> > >> > >> [1] > >> > https://github.com/BaseXdb/basex/blob/382c8097afb1ec5bac1e9511a2287686c33f669d/basex-core/src/main/java/org/basex/util/http/HttpRequestParser.java > >> > >
Written for BaseX 9.5. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery