Closed LaG1924 closed 3 years ago
GET requests with json content type have no body. You should use POST, or x-www-form-urlencoded
content type.
I see. Yes, that does make sense, but what should I do if API requires to be every request in JSON? Even empty GET requests (in that case body must be only {}
). I tested such behavior in python (with requests library) and it works perfectly.
And I just found #99 which sounds very familiar.
It's not a way REST api should be used, and it's not supported with json content type right now in the engine itself. Please provide an example of public API you're trying to work with.
Also you can check x_www_form_urlencoded_body
request type, maybe it'll help you.
https://developers.home-assistant.io/docs/api/rest/
That was my mistake about "body is {}
". Actually, that's API needs just "content-type" to be set to "application/json". So, can I just override "content-type" header for x-www-form-urlencoded?
I've checked the api, and you shouldn't pass any parameters in json or body form to server for GET requests
Yes, and I already wrote about that.
But I still have to use application/json
as Content-Type
header value. I believe this is easily solvable.
I think you can close the issue.
Got the idea. Please try this in VaRestRequestJSON.cpp
:
Unfortunately, I hoped to use this library as a quick-and-dirty solution to prototype some features before using C++. But for now (especially if I will need to modify the plugin's code) it will be simpler for me to implement features directly in code, not in blueprints.
If you still want me to test these changes, then I can find time to do this... next week?
@LaG1924 I've sent an update to Marketplace, hope it'll be processed soon (for UE 4.26 and UE 4.27)
my VaRest worked for 3 days, now "GET" stopped permanently
tl;dr: when request type is GET and Content-Type is Json, "Content-Length" is non-zero but body not send.
Hello. This is my first experience with this library, so it's maybe just me using this library's API in the wrong way. I'm trying to make a test GET request, but it just does not work (no PrintString node on fail/completed callback). So, I started investigation: In logs was the next messages:
After spending some time debugging the web server I figured out that it was a malformed request send by the library:
It's declaring the request's "Content-Length" header but does not send the body (request end with two newlines), so the web server is still waiting for data and not sending a response.
But for POST (I didn't test other methods) it successfully sends the body with the correct "Content-Length" header. For Content-Type "x-www-form-urlencoded (URL)" it sets "Content-Lenth: 0", so it works too.