VaRest icon indicating copy to clipboard operation
VaRest copied to clipboard

GET with requestbody does not send body, but POST does

Open cevanno opened this issue 3 years ago • 2 comments

I am using an API that requires all request parameters be a JSON object in the request body (x-www-form-urlencoded(Request Body)), instead of as url inline parameters. This works great for POST requests but not for GET requests with VaRest so far and I'm hoping for some help to understand what I'm doing wrong, or if the product doesn't support GET with a request body (even though the Node settings are available and make it appear as if it should work). Here's what I'm doing (see attached). Using ConstructJsonRequest node and ApplyURL I attempt to make a request object and get the server response. This design is great because I can change just the Verb and see what happens. When the Verb=POST the expected request message with json body is sent. This is good debugging information but does not solve my problem because I must use the API as provided and for some calls it uses GET. When Verb=GET the ApplyURL never sends the message and never returns so the Unreal Exec thread ends/hangs. This is really bad because there is no way to check when a node never returns. Unreal reports this log: LogVaRest: UVaRestRequestJSON::ProcessRequest(405): Request (url body): GET http://xxxserverxxx:3000/login (check bExtendedLog for additional data) and then some time later it reports: [2022.02.22-22.37.03:938][487]LogHttp: Warning: 000001FD969D9D00: HTTP request timed out after 180.00 seconds URL=http://xxxserverxxx:3000/login [2022.02.22-22.37.03:938][487]LogHttp: Warning: 000001FD969D9D00: request failed, libcurl error: 0 (No error) [2022.02.22-22.37.03:938][487]LogHttp: Warning: 000001FD969D9D00: libcurl info message cache 0 (Connection 37 seems to be dead!)

Where is this bExtendedLog and is it implied there is a way to enable more detailed logging by checking bExtendedLog??

Alternatively, if the Verb=GET but the Content Type is set to all the other options (urlencoded(URL), JSON, Binary) a message IS sent to the server but there is no body so the server responds with a properly formed JSON error message body that is returned as the Result from ApplyURL. For completeness I've tried and verified the CallURL and ProcessURL nodes also do not work with similar hanging behavior.
See this simple example. The printstring verifies that the proper json object has been created. image

cevanno avatar Feb 22 '22 22:02 cevanno

That's not what GET requests are for... they are for retrieving data via endpoints with additional URL parameters.

No properly designed REST API should have body data in a GET.

kardall avatar Mar 03 '22 23:03 kardall

hehe, I'll be sure to let the product designers know that. I feel ya. I'd not seen it before and while my main goal is to get stuff to work, your message prompted me to look around a bit. Lots of discussion on this point with strong objections. However, apparently its a lot more common now that it became legal in the RFC back in 2014. So maybe the acceptable practices are just growing into the spec. Again, I'm not defending the fact that I have to deal with this kind of api. Prefer a generic VaRest tool not take sides and just support the RFC.

cevanno avatar Mar 14 '22 22:03 cevanno