Think I found it
it turns out that the httpClient(idHTTP).POST wont accept a Tstringlist as part of it's parameters. It allows it but dosent convert it correctly.
I needed to do this
Params := TStringStream.Create();
Params.WriteString('{"filter":{ }}');
and call httpClient.Post(URL,Params,res);
the response (res) also arrives in a TStringStream.. all I have to do now is make sense of the response then I can get back to figuring out where these memory leaks are comming from..
Kind Regards
OzPunter
errors trying to make basic calls
Collapse
X
-
I've tried everyting I can think of and every respose is HTTP/1.1400 Bad Request
I've run out of things to try... Has anyone got code that works?? anyone??
OzPunter
Leave a comment:
-
Here's an update.. I made a new procedure to send a "keep Alive" request and got back a Success response, alo tried it when logged out and got back an error message.. So as a test that's encouraging.. all I have to do is figure out why I'm getting Bad Request for the listEventTypes...Originally posted by OzPunter View PostThanks for your help BetDynamics, but..
ContentType = 'application/x-www-form-urlencoded';
or 'application/json';
and Contentlength set to any of the length of the URL, or the filter or both (URL+Filter) all produce the Bad Request error.
Kind Regards
OzPunter
Leave a comment:
-
Thanks for your help BetDynamics, but..
ContentType = 'application/x-www-form-urlencoded';
or 'application/json';
and Contentlength set to any of the length of the URL, or the filter or both (URL+Filter) all produce the Bad Request error.
Kind Regards
OzPunter
Leave a comment:
-
Don't you need to specify Content-Type and Content-Length in your httpClient?
Leave a comment:
-
the code
procedure TForm1.Button2Click(Sender: TObject);
var
httpClient : TIdHttp ;
sslIOHandler : TIdSSLIOHandlerSocketOpenSSL ;
Response : string ;
error : string;
lParamList: TStringList;
begin
lParamList := TStringList.Create;
lParamList.Add('{"filter" :{}}');
Error := '' ;
Response := '' ;
httpClient := TIdHttp.Create(nil) ;
httpClient.Request.Accept := 'application/json' ;
httpClient.ReadTimeout := 60000 ;
httpClient.Request.CustomHeaders.Add('X-Authentication:' + SessionToken ) ;
httpClient.Request.CustomHeaders.Add('X-Application:' + App_Key ) ;
sslIOHandler := TIdSSLIOHandlerSocketOpenSSL.Create(nil) ;
httpClient.IOHandler := sslIOHandler ;
Response := httpClient.Post('https://api.betfair.com/exchange/betting/rest/v1.0/listEventTypes/',lParamList);
freeandnil(lparamList);
memo1.text := response;
end;
The code fails on the httpClient.Post with "HTTP/1.1415 Unsuported Media Type"
If I try a ".get" the error is "HTTP/1.1400 Bad Request", so "Gets" are the wrong call..
I'm logged in and the session and appkey are valid.
What I'm really trying to get to the bottom of is why I have memory leaks when making JSON calls.. So the aim of this code is to determine where the memory leaks are coming from... My previous project works ok, for about 2 hours and crashes through memory problems.
Leave a comment:
-
Did you set the X-Application and X-Authentication headers before making the calls?
Leave a comment:
-
errors trying to make basic calls
In an attempt to circumvent a whole pile of code that could be contributing to the Memory Leaks problem, I have started from scratch with the barest minimum code.
Regardless of what I try I end up with either “Invalid Requests”, “404 errors” or “Invalid media type”
This is what I’m POSTing;
httpClient.Post('https://api.betfair.com/exchange/betting/rest/v1.0/listEventTypes/',lParamList);
where IParamlist is
lParamList := TStringList.Create;
lParamList.Add('{"filter" :{}}');
And the response is “Invalid media type”
So I’m not getting anywhere, and time is running out…
If I can't find a way around these memory leaks, the whole thing is sunk.Tags: None


Leave a comment: