rivetweb
(X Y)
August 19, 2018, 2:18pm
1
https://api.haxe.org/haxe/Http.html#requestUrl
staticrequestUrl (url:String):String
This creates a new Http instance and makes a GET request by calling its request(false)
method.
If url
is null, the result is unspecified.
I need to make POST request but i dont need to make this callbacks in example
how i can do it?
ibilon
(Valentin Lemière)
August 19, 2018, 3:32pm
2
You need to create the http object var request = new haxe.Http(url);
, then optionally set the post data using request.setPostData(data);
and finally send the request with request.request(true);
.
rivetweb
(X Y)
August 19, 2018, 5:05pm
3
i already do this
but how to get response content?
request (?post:Bool):Void
this method didnt return content
ibilon
(Valentin Lemière)
August 19, 2018, 8:32pm
4
You need to set the onData variable, for instance:
var response = "";
request.onData = function (data) {
response = data;
}
request.request(true);
// now you have response filled
You may want to set onError too do deal with errors.
rivetweb
(X Y)
August 21, 2018, 4:59am
5
ок
i have other problem
var result = ‘’;
req.onData = function (data:String)
{
trace(data);
}
req.onError = function (error)
{
trace(req);
trace(error);
trace(‘error’);
}
req.request(true);
for error http request i got only short error msg
Main.hx:28: haxe.Http
Main.hx:29: Http Error #400
Main.hx:30: error
how to get all responsetext of error response? like in onData handler?
rest api server turn error content in response like {“error”: SOME_ERROR_CODE, “error_description”: “blablabla”}
and status 400
how to get this error content?
kLabz
(Rudy Ges)
August 21, 2018, 5:14am
6
error
is already a string here, it’s the message you’re receiving.
Maybe you need to pass the accept header in order to get the json response?
Something like req.addHeader('accept', 'application/json')
rivetweb
(X Y)
August 21, 2018, 10:17am
7
not work - same error
Main.hx:28: haxe.Http
Main.hx:29: Http Error #400
Main.hx:30: error
rivetweb
(X Y)
August 21, 2018, 10:20am
8
how to get response content? (req.responseText not work too)
rivetweb
(X Y)
August 21, 2018, 10:23am
9
opened 04:29AM - 28 May 13 UTC
closed 04:29AM - 28 May 13 UTC
[Google Issue #1066 : https://code.google.com/p/haxe/issues/detail?id=1066]
by akryva...@gmail.com, at 18/07/2012, 15:19:37
What steps will reproduce the problem?
Send something that will result in error #2032
What...
same ploblem - status closed
but not implemented?