Angus Robertson 574 Posted August 8, 2019 Probably not, since you asked the component to send from the end of the stream, not the beginning. you need Stream.Seek(0, soFromBeginning). If you are using TSslHttpRest most of thar code is not necessary since it builds Json for you. Angus Share this post Link to post
ZRomik 2 Posted August 8, 2019 I add code FSndStrm.Seek(0, soFromBeginning); But this not helps. I recieve from server "{"error":"too few items for 'names', 'names' is required"}" Share this post Link to post
FPiette 384 Posted August 8, 2019 Do you have another application able to request the same server? If you do, I suggest you use WireShark to spy on the data passing thru the network from that application and then do the same with you own application. Comparing to two traces, you'll probably discover what is wrong in the data formatting you use. Share this post Link to post
ZRomik 2 Posted August 8, 2019 OK. I'll try to find another app. Tnanks for advise. Share this post Link to post
ZRomik 2 Posted August 8, 2019 I'm download and run Wireshark. Set filter as "ip.dst == 52.51.209.180"(ping to esi.evetech.net gave me that address). But wireshark does't seen any packet to host, exclude ping Share this post Link to post
ZRomik 2 Posted August 8, 2019 Looks like program not send any data to host Share this post Link to post
FPiette 384 Posted August 9, 2019 In a previous message you told us you get back an error message from the server, right? Go back to this situation and using WireShark, capture the request and the response. Compare it with the "reference" application. Share this post Link to post
ZRomik 2 Posted August 10, 2019 I set breakpoint at line cli1.Post and look inside component code: In method AdjustDocName field FDocName changed from '/latest/universe/ids/' to 'document.htm' When we enter in method "TCustomWSocket.DnsLookup" the field "FDnsLookupHandle" is equal 0 and code after line 9438( unit OverbyteIcsWSocket.pas) not executing. So, we not execute DnsLookup and DnsList is clear. As I understud we not establish connection with server and not sent any data Share this post Link to post
ZRomik 2 Posted August 10, 2019 About error Bad request: The exception class is EHttpException. This class described in unit OverbyteIcsHttpProt.pas. Its's not response from server, but internal component error as I understad. Quote Jan 23, 2012 V7.23 Arno added httperrNoStatusCode, passed to OnRequestDone and raised in sync mode if connection closed prematurely. Always raise EHttpException with the internal httperror code rather than the HTTP status code if FRequestDoneError is set, this changed EHttpException's ErrorCode property value of abort and timeout exceptions. Share this post Link to post
FPiette 384 Posted August 11, 2019 Sorry, I have no idea. It looks like you feed bad parameters to the component. I suggest you restart from beginning, starting with the samples provided which are working. Then modify the sample step by step until it either works for you or fail. If it fails, use the debugger to try understand what is wrong. Share this post Link to post
ZRomik 2 Posted August 11, 2019 1 hour ago, FPiette said: Sorry, I have no idea. It looks like you feed bad parameters to the component. I suggest you restart from beginning, starting with the samples provided which are working. Then modify the sample step by step until it either works for you or fail. If it fails, use the debugger to try understand what is wrong. In examples I can't find sample with post request. Share this post Link to post
Angus Robertson 574 Posted August 11, 2019 As I told you back in March, use the OverbyteIcsHttpRestTst.dproj sample which allows you to specify the Json parameters for your POST request. Angus Share this post Link to post
ZRomik 2 Posted August 19, 2019 Angus, I'm really can't find where specifyed Json parameters in example you told Share this post Link to post
Angus Robertson 574 Posted August 19, 2019 The OverbyteIcsHttpRestTst.dproj sample has a grid titled REST Parameters where you enter multiple Names and Values, select REST Content as Json, request type POST and enter your URL. If a Json response is returned, it is also displayed as a grid. The OverbyteIcsSslHttpRest.pas unit itself has several examples of setting RestParams using code, for making OAuth requests, DNS over HTTPS and SMS. and OverbyteIcsSslX509Certs.pas has numerous examples ordering SSL certificates. Beware the RestParams properties don't easily handle arrays, sometimes it's easier to build the parameters using a Jspn library, ICS includes SuperObject which works with all versions of Delphi, since Json was only added to the Delphi language in more recent versions. Angus Share this post Link to post
ZRomik 2 Posted August 24, 2019 (edited) On 8/19/2019 at 1:49 PM, Angus Robertson said: The OverbyteIcsHttpRestTst.dproj sample has a grid titled REST Parameters where you enter multiple Names and Values, select REST Content as Json, request type POST and enter your URL. If a Json response is returned, it is also displayed as a grid. The OverbyteIcsSslHttpRest.pas unit itself has several examples of setting RestParams using code, for making OAuth requests, DNS over HTTPS and SMS. and OverbyteIcsSslX509Certs.pas has numerous examples ordering SSL certificates. Beware the RestParams properties don't easily handle arrays, sometimes it's easier to build the parameters using a Jspn library, ICS includes SuperObject which works with all versions of Delphi, since Json was only added to the Delphi language in more recent versions. Angus I tried to do that you say, but got error too. Quote POST https://esi.evetech.net/latest/universe/ids/ {"names":[\"water\"]} Async request started Connected OK to: esi.evetech.net (34.248.103.232) > POST /latest/universe/ids/ HTTP/1.1 > Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */* > Accept-Encoding: gzip, deflate > Content-Type: application/json; charset=UTF-8 > User-Agent: Mozilla/4.0 > Host: esi.evetech.net > Content-Length: 21 > Authorization: Bearer 1|CfDJ8HHFK/DOe6xKoNPHamc0mCWDxGEmxFRUkc+z70lyhp9t80eZRXMbUNkSGeGN6FegDZbhXS50FQd9S661Xqy13guYB4SlTGflVH17Gd9ICEPizz3UILtQZavW70eo4BvXpQujhUaFBkIaEpmB8xuRe//qF/dAZcIjA+5fQzYqmPYP > esi.evetech.net SSL Connected OK with TLSv1.2, cipher ECDHE-RSA-AES128-GCM-SHA256, key auth RSA, key exchange ECDH, encryption AESGCM(128), message auth AEAD < HTTP/1.1 400 Bad Request < Date: Sat, 24 Aug 2019 19:41:45 GMT < Content-Type: application/json; charset=UTF-8 < Content-Length: 58 < Connection: keep-alive < Access-Control-Allow-Credentials: true < Access-Control-Allow-Headers: Content-Type,Authorization,If-None-Match,X-User-Agent < Access-Control-Allow-Methods: POST,OPTIONS < Access-Control-Allow-Origin: * < Access-Control-Expose-Headers: Content-Type,Warning,ETag,X-Pages,X-ESI-Error-Limit-Remain,X-ESI-Error-Limit-Reset < Access-Control-Max-Age: 600 < Allow: OPTIONS,POST < Strict-Transport-Security: max-age=31536000 < Vary: Accept-Language < X-Esi-Error-Limit-Remain: 99 < X-Esi-Error-Limit-Reset: 15 < X-Esi-Request-Id: b794dc84-eebf-42dc-8a4c-58aaacde3b2c Request completed: 400 Bad Request Request done, StatusCode #400 {"error":"too few items for 'names', 'names' is required"} Json main content type: stObject This is the example from server Quote curl -X POST "https://esi.evetech.net/latest/universe/ids/?datasource=tranquility&language=en-us" -H "accept: application/json" -H "Accept-Language: en-us" -H "Content-Type: application/json" -d "[ \"water\"]" I tried to use both address string: "POST https://esi.evetech.net/latest/universe/ids/?datasource=tranquility&language=en-us" and "POST https://esi.evetech.net/latest/universe/ids/" with same result Edited August 24, 2019 by ZRomik Update log text Share this post Link to post
ZRomik 2 Posted August 24, 2019 (edited) I tried to build manual the parameters with SuperObject but still got error Edited August 24, 2019 by ZRomik Share this post Link to post
Angus Robertson 574 Posted August 25, 2019 None of you logging shows the Json parameters you are actually sending to the server, but then we don't know what parameters or authorisation the server requires, and that is outside the scope of ICS support here. I would suggest you try making REST requests to another simpler server first to prove you are using ICS correctly, the REST sample has several simple demos, then worry about your specific application. The error you got {"error":"too few items for 'names', 'names' is required"} suggests you are sending the wrong parameters. Angus Share this post Link to post
ZRomik 2 Posted August 26, 2019 all that had to be done was to add this code. cli1.Accept := 'application/json;'; Now I successfull recieve data from server. Thanks for help! Share this post Link to post
ZRomik 2 Posted August 27, 2019 Angus, is there possible get response from server not by event, like in Synapse eg Share this post Link to post
Angus Robertson 574 Posted August 27, 2019 That is what we call async and sync methods. Angus Share this post Link to post
ZRomik 2 Posted August 27, 2019 (edited) Can you tell me more how to do this? Edited August 27, 2019 by ZRomik Share this post Link to post
Angus Robertson 574 Posted August 27, 2019 ICS comes with lots of samples, there is also a wiki to read, I can not write your application here,. The REST example I explained on 19 August could not make it any plainer, the screen says Sync Request or Async Request. Sometimes I suspect you ignore my advice. Angus Share this post Link to post
ZRomik 2 Posted September 4, 2019 (edited) Another question about HttpCli. How do I know if a component is ready to work? Sometime I get error Quote HTTP component is busy. Edited September 4, 2019 by ZRomik Share this post Link to post
Angus Robertson 574 Posted September 4, 2019 You only get that error if you are misusing the component. It means an async operation is still in progress and you are attempting to start another operation. With async use, you need to wait for the onRequestDone event to fire before starting something new. You can also check the State property for httpReady. Angus Share this post Link to post