Jump to content

ZRomik

Members
  • Content Count

    54
  • Joined

  • Last visited

Posts posted by ZRomik


  1. Hi!

    I wrote small app for Android for test. In OnCreate method  I request Some permission from OS

      FStorageRead  := JStringToString(TJManifest_permission.JavaClass.READ_EXTERNAL_STORAGE);
      FStorageWrite := JStringToString(TJManifest_permission.JavaClass.WRITE_EXTERNAL_STORAGE);
      FReadSms      := JStringToString(TJManifest_permission.JavaClass.READ_SMS);
      PermissionsService.RequestPermissions([FReadSms, FStorageRead, FStorageWrite], nil, DisplayRationale);

    So, only requests READ_EXTERNAL_STORAGE and WRITE_EXTERNAL_STORAGE works fine.

    Is anybody know why READ_SMS permission not requested? I use for test my Xiaomi Redmi Note 4 with MIUI-10 on Android 6.0.

    On Android emulator is the same thing.


  2. 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


  3. 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.


  4. 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.
     


     


  5. 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

  6. Again trying  send post-request as follow:

      if Not Assigned(FRcvStr) then
        FRcvStr := TMemoryStream.Create;
        if not Assigned(FSndStr) then
          FSndStr := TMemoryStream.Create;
          s := '{"names": ["Water"]}';
          FSndStr.Write(s[1], Length(s));
          cli1.SendStream := FSndStr;
          cli1.RcvdStream := FRcvStr;
          cli1.PostASync;

    So, If I use method Post then I get eror "BadRequest". If I use method PostAsync then I got  answer; "{"error":"too few items for 'names', 'names' is required"}". Looks like data not sending to server.

×