Announcement

Collapse
No announcement yet.

HTTP.SubmitSecure (with private API key)

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • HTTP.SubmitSecure (with private API key)

    Hey guys,

    Can anyone help me figure this out?

    Am trying to use a private API Key in an HTTP.SubmitSecure request to return the price of XMR (cryptocurrency). But for some reason, I keep getting a blank string returned. Am a little puzzled why?

    If I submit the following URL (with private API key appended):

    Code:
    [URL="https://min-api.cryptocompare.com/data/price?fsym=XMR&tsyms=AUD&api_key=%7Bmy_private_api_k%20ey%7D"]https://min-api.cryptocompare.com/data/price?fsym=XMR&tsyms=AUD&api_key={my_private_api_key}[/URL]
    ...via my browser, it will correctly return the price of XMR:

    eg. screenshot:



    But when attempting to retrieve the same data via AMS with the following code:

    Code:
    sRet = HTTP.SubmitSecure("https://min-api.cryptocompare.com/data/price?fsym=XMR&tsyms=AUD&api_key={my_private_api_k ey}", {}, SUBMITWEB_GET, 20, 443, nil, nil);
    Dialog.Message("Notice", sRet);
    ...all that I get is a blank string.

    Anyone know why?


  • #2
    Good to see yah Bio,
    You have a TYPO ERROR space between _k and e maybe

    Comment


    • #3
      Yes, I'm aware of the typo, thanks Col. It's where my private API key goes (which in this particular case is an indeterminate alpha-numeric string).

      This is really bugging me, guys. Anyone know what's going on with this little mystery?

      Comment


      • #4
        Have you tried passing the arguments

        fsym=XMR
        tsyms=AUD
        api_key={my_private_api_key}

        in the values table, instead of using it as part of the URL?

        Code:
        local sValues = { fsym="XMR", tsyms="AUD", api_key="{my_private_api_key}"};
        
        sRet = HTTP.SubmitSecure("https://min-api.cryptocompare.com/data/price", sValues, SUBMITWEB_GET, 20, 443, nil, nil);
        Dialog.Message("Notice", sRet);

        Ulrich
        Last edited by Ulrich; 12-30-2020, 10:02 AM. Reason: Typo

        Comment


        • #5
          Hey Ulrich,

          I've tried passing the arguments thru a values table like you suggest but it doesn't seem to make a difference - still get nothing back. Have also tried passing just the api-key through the values table (with the crypto & currency values appended to the URL) - still nothing.

          I'm not even sure where to start digging on this one?

          Comment


          • #6
            Just tried the code exactly as above, and received this reply:

            Click image for larger version

Name:	SCRN-2020-12-30-02.png
Views:	132
Size:	1.3 KB
ID:	305905
            So I got something, but without a valid API key, probably nothing useful. Strange that you say that you do not get anything back from the server.

            Ulrich

            Comment


            • #7
              Yes, I'm aware that one can return basic data without an api-key:

              eg.

              ..returns price of Monero in Australian Dollars


              ... returns price of Bitcoin in US Dollars

              etc, etc...

              The API-Key just provides an ability to return a range of data otherwise unavailable.

              However ... I'm still getting the same problem even when no API-Key is used (ie. I still get nothing returned). So yes, it's quite strange that you're successfully getting data back. Ulrich, if it's not too much trouble, would you mind uploading the APZ used for your screenshot - so I can figure out what the heck I'm doing wrong?

              Am now suspecting it's possibly a local issue with my computer. Or possibly even an AMS version-related issue. Most likely though, am guessing it's just me - having another one of my Homer Simpson moments. D'oh!

              Comment


              • #8
                Here it is...
                Attached Files

                Comment


                • #9
                  Thanks, Ulrich.

                  This reveals an interesting anomaly. Seems my initial suspicion was correct - it appears to be a local issue with my machine.

                  Running your .apz under my WinXP machine returns the following error:



                  ... or (of course) returns nothing at all, if I omit the error-checking code.

                  But when I run it on my Win7 machine, then no problems at all.

                  The perculiar thing though is that if I run an HTTPS.SubmitSecure 'GET' request on https://google.com via my WinXP machine, it works just fine! Seems WinXP doesn't like that particular URL (nor any URL returning a JSON formatted string). Is quite bizarre - never seen anything like it!

                  LOL, 'bout time I got rid of that old WinXP laptop, anyway. Be sticking with my Win7 desktop installation from now on!
                  Many thanks for your help, brother.

                  Comment

                  Working...
                  X