Rocket U2 | UniVerse & UniData

 View Only

 Does submitRequest() ignore post_data when HTTP verb is DELETE?

Jump to Best Answer
John Sherman's profile image
PARTNER John Sherman posted 10-11-2021 17:58
Hi,
I'm on UniVerse 11.1.9 running on Linux.  My question is about the CallHTTP function, submitRequest().  I'm using code like the below to communicate with an external web service.

result = createRequest(PROXY.URL,http_method,request_handle)
IF result # 0 THEN ERRORS<-1> = 'createRequest() failed with return code ':result; GO FATAL.ERROR

result = setRequestHeader(request_handle,"Content-Type","application/json")
IF result # 0 THEN ERRORS<-1> = 'setRequestHeader() failed with return code ':result; GO FATAL.ERROR

result = submitRequest(request_handle,30000,post_data,response_headers,response_data,http_status)​


It seems that when the http_method passed to createRequest() is DELETE, then submitRequest() ignores the post_data passed to it.  That is to say the value of post_data is not included in the body of the request.

Can any confirm if this is expected behavior?
Aaron Glover's profile image
Aaron Glover Best Answer
I cant confirm this expected but its not at all surprising if it is the case. I've seen this behaviour of HTTP clients on different platforms, I've also seen web servers which ignore the request body for HTTP DELETE methods.

The standard isn't clear on this topic so its down to interpretation by client implementors. If its your API you are calling and you have the option to redesign the semantics of the API then i would suggest employing a more RESTful API approach; of course I don't know your situation in detail but thats my two cents. You can definitely hit this problem on different platforms.
Steve Wingfield's profile image
ROCKETEER Steve Wingfield
Hi John,

Yes, BASIC's CallHTTP submitRequest function ignores the payload if the HTTP verb is DELETE.  And this is for the reasons that Aaron mentioned in his answer - namely that the RFC for HTTP 1.1 has traditionally left this undefined.  The latest RFC (https://datatracker.ietf.org/doc/html/rfc7231#section-4.3.5) states

   A payload within a DELETE request message has no defined semantics;
   sending a payload body on a DELETE request might cause some existing
   implementations to reject the request.
  There is some discussion on this topic at Stack Overflow:  https://stackoverflow.com/questions/299628/is-an-entity-body-allowed-for-an-http-delete-request
John Sherman's profile image
PARTNER John Sherman
Thanks, everybody!  For what it's worth, I did read the RFC and do a bit of web searching before posting here.  That's why it was a forum post and not a bug filing :-) The "external service" is indeed my own API so I'll just tweak it as Aaron suggested.  Thanks again!