Unable to create HTTP client. Make sure LibreOffice is configured to allow HTTP requests

Perhaps you could start with showing what code you first tried before you went down the ChatGPT rabbit hole. And perhaps describe what you hope to return from the website.

Rob thank you I will do that then. Does it matter that this other code is mainly through ChatGTP but wi5h some input from me?

but at least generates something …

and probably get requests over some long legacy of guilty silence or vagueness ? :wink:

Given the quality of chatgpt coding we have already seen, that might be a waste of time. If the links @fpy has provided don’t help, perhaps come back with specific questions. You might also, as mentioned before, tell what is the task you need to undertake that you think needs a macro with http connectivity.

You write that as if it is better to generate a nonsensical answer to one’s question, waste the questioner’s time trying to make the answer work, waste time of others who try to help the questioner when they turn to the Ask site seeking for clarification… and now that non-existent service name has appeared here on the Ask LibreOffice site, adding to the noise of the Internet.

No idea what could that mean. Possibly you hint on something, but not everyone could guess.

<meta_debate>

just illustrated by the 2 Ask LibreOffice posts I linked.
one with zero answer,
the other one so open that it may be not so far from AI generated one :wink:

interesting topic …
even when there are blessed marked solutions, filtering them out to figure out what to do with them remains a lot of work :wink:

</meta_debate>

It would probably be smarter to use a decent programming language and the documentation available there, instead of letting “ChatGPT” write Basic-code-poems for you!

Or call the almighty curl command line tool from LO. :slightly_smiling_face:

Please stop trying to put equality between useful answers that might need more work, and nonsense that is 100% wrong. No answer is infinitely better than garbage made up answer. When people don’t know an answer, they may try to point to a direction that might be useful (explaining that it is a possibility), or keep silent, but won’t invent names of non-existent services. Period, no “debate”.

1 Like

pm sent…

Rob or anyone who might help.
Ok so here goes what I am trying to achieve is a spreadsheet with a list of the optOut addresses and the Balance Amount of WFLR in each address and an aggregated total balance.

The BASIC script should first connect via http somehow to gather optOut addresses from 20.optOutAddresses in the original contract by running a loop starting at “0” and ending when an error message “(error) : (-32000) execution reverted “ is returned (approximately 220 addresses) instead of a valid address that starts with “0x”
and then next query the balance of WFLR for each opt-out address in the new contract at 2.balanceOf

Original contract DistributionToDelegators (0x9c7A4C83842B29bB4A082b0E689CB9474BD938d0) - Flare Explorer

New contract

The script so far as provided mostly by AI is as follows but it does not work and I am not clever enough to identify and rectify so I am appealing to this forum for help.

I have Libre Office Calc version Version: 7.6.4.1 (X86_64) / LibreOffice Community
Build ID: e19e193f88cd6c0525a17fb7a176ed8e6a3e2aa1
CPU threads: 8; OS: Windows 10.0 Build 19045; UI render: Skia/Raster; VCL: win
Locale: en-AU (en_AU); UI: en-GB
Calc: threaded

I have installed the getrest.oxt extension

' Function to parse JSON response and extract WFLR amounts
Function ParseResponse(jsonResponse As String) As Double
    ' Convert JSON response to a dictionary object
    Dim json As Object
    json = ParseJSON(jsonResponse)
    
    ' Initialize WFLR value
    Dim wflrValue As Double
    wflrValue = 0
    
    ' Assuming the JSON response is a dictionary with keys as addresses and values as WFLR amounts
    Dim address As Variant
    For Each address In json.Keys()
        wflrValue = wflrValue + json(address)
    Next address
    
    ' Return total WFLR value
    ParseResponse = wflrValue
End Function

Sub QueryContracts()
    Dim optOutAddresses() As String
    Dim totalWFLR As Double
    Dim index As Integer
    
    ' Initialize total WFLR and index
    totalWFLR = 0
    index = 0
    
    ' Loop to gather optOut addresses from the original contract
    Do
        ' Construct URL for the original contract
        Dim url As String
        url = "https://flare-explorer.flare.network/address/0x9c7A4C83842B29bB4A082b0E689CB9474BD938d0/read-contract?20.optOutAddresses[" & index & "]"
        
        ' Make HTTP GET request using GetRest extension
        Dim optOutJsonResponse As String
        optOutJsonResponse = GetRest(url)
        
        ' Parse JSON response to get optOut address
        Dim optOutAddress As String
        optOutAddress = ParseResponse(optOutJsonResponse)
        
        ' Check if optOut address is valid
        If optOutAddress <> "" Then
            ' Add optOut address to array
            ReDim Preserve optOutAddresses(index)
            optOutAddresses(index) = optOutAddress
            
            ' Increment index for next optOut address
            index = index + 1
        Else
            ' Exit loop if no more optOut addresses found
            Exit Do
        End If
    Loop
    
    ' Query balance of WFLR for each optOut address in the new contract
    For Each optOutAddress In optOutAddresses
        ' Construct URL for the new contract
        Dim newContractUrl As String
        newContractUrl = "https://flare-explorer.flare.network/token/0x1D80c49BbBCd1C0911346656B529DF9E5c2F783d/read-contract?2.balanceOf=" & optOutAddress
        
        ' Make HTTP GET request using GetRest extension
        Dim balanceJsonResponse As String
        balanceJsonResponse = GetRest(newContractUrl)
        
        ' Parse JSON response to get balance of WFLR
        Dim balance As Double
        balance = ParseResponse(balanceJsonResponse)
        
        ' Add balance to total WFLR
        totalWFLR = totalWFLR + balance
    Next optOutAddress
    
    ' Output total WFLR to cell A1 in the current sheet
    ThisComponent.Sheets(0).getCellByPosition(0, 0).Value = "Total WFLR: " & Format(totalWFLR, "0.00")
End Sub

why would it have to be in BASIC ?

maybe let’s try to (re)start on stable ground, not sure though what is your actual level in programming or tooling …

have you an understanding for example of this :

fpy Stable ground sounds like a good place to start. I am not a coder or developer of any sort but I have compiled a whole array of spreadsheets but only one with an API call so my understanding is not very good in this area.
I know what I want and how and where to connect to in achieving my aim but I do not know the HOW. That’s why I turned to AI for assistance. The language does not have to be BASIC as it could be anything that will work from within Libre Office Calc. I have read through a lot of the posts and links but my base grounding on the syntax in constructing macros leaves me scratching my head somewhat.
I am most certainly open to suggestions or directions if you or anyone can help. Thanks

thing is, the know HOW, often makes reconsider the “where to” :wink:

To get more familiar with this flare API, you can play with
https://flare-explorer.flare.network/graphiql
from the link I referenced above, seems the balance or balancemulti function might go towards what you want to do … ?

and for calc, try WEBSERVICE() like roughly shown in the sheet attached
flare.ods (8.3 KB)

Maybe also check other existing tools like
https://docs.flare.network/dev/tools/

1 Like

Thank you for taking the time to have a look and advise. i will explore these avenues firstly.

Thank you for your help but after looking through these links and other reading and videos I think this might just be beyond my capabilities, unfortunately. I will keep trying in the background but could you maybe just advise me of the broad outline of what I need to do ie Which language is best BASIC etc, which function do I use WEBSERVICE() or getRest.oxt to make the web connections?

At this point, try to ping the providers to get a (first free) subscription and see what is actually available

Otherwise, seems even manual interactions (like the 20.optOut form you mentionned) are limited.
Couldn’t get a csv either
https://flare-explorer.flare.network/csv-export?address=0x9c7A4C83842B29bB4A082b0E689CB9474BD938d0&type=transactions

Thank you for these links and suggestions. I have had a look through and to me it does not appear to provide me with a way to gather the information I am seeking. But that may be a product of my lack of technical coding abilities and understandings.

My thoughts were simply to access both of the websites containing the two contracts of interest via a HTTP connection out of Calc based on the criteria I have prescribed.
Is this not possible to set up automatically via a macro script written in the appropriate language as I can certainly do these actions manually using the two website addresses above? But I would need to do tis some 220 times to gather the addresses then another 220 times submitting those qualified addresses to the second contract to find their holding amount then add them all together. My need for this macro is to provide proof that my calculations in several spreadsheets I have done are actually factual and accurate. The aggregate total will provide the number I need to prove or disprove my other calculations in these spreadsheets.
is the AI code I posted anywhere near being able to do this with some adjustments and corrections?

No, if you remember

Lets put it in the real world: You asked for help to get “abcdef”. AI said give your Corvette to your daughter Cindy and let her drive 200 miles to the east. Then buy at Acme-shop with credit card “Silver-Surfer 24”.
.
My guess is this is impossible for you.
Can you fix it?
.
Is it possible to buy a Corvette…
It will take time to raise a daughter…
If you live on the american east coast, it could be quite difficult to drive eastwards…
etc.
.
For computing: Yes this can be fixed, but therefore you have to to fill the stuff AI imagined. So actually you solve the problem, but will name the solution as AI suggested. So maybe name your next child Cindy…

Thank you for dropping by with your very helpful advice. Enjoy your life.