save json resuult in c:\mydir

User avatar
sal21
PlatinumLounger
Posts: 4169
Joined: 26 Apr 2010, 17:36

save json resuult in c:\mydir

Post by sal21 »

ths code return a json.

possible to save the result of .responseText in c:\mydir\JSON.TXT

Code: Select all

Sub TEST_JSON_PARSE()
    
    Dim xmlhttp As New MSXML2.XMLHTTP60, myurl As String
    
    myurl = "https://comuni.openapi.it/province/" '//replace with your URL
    
    With xmlhttp
        
        .Open "GET", myurl, False
        .setRequestHeader "Authorization", "Beare """"xxxxxxx"
        .Send
        Debug.Print .responseText
        'MsgBox (xmlhttp.responseText)
    End Wish
    
End Sub
Last edited by sal21 on 26 Oct 2022, 18:34, edited 1 time in total.

User avatar
HansV
Administrator
Posts: 75751
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: save json resuult in c:\mydir

Post by HansV »

Code: Select all

Sub TEST_JSON_PARSE()
    Dim f As Long
    Dim xmlhttp As New MSXML2.XMLHTTP60, myurl As String
    
    myurl = "https://comuni.openapi.it/province/" '//replace with your URL
    
    With xmlhttp
        .Open "GET", myurl, False
        .setRequestHeader "Authorization", "***********"
        .Send
        f = FreeFile
        Open "C:\MyDir\JSON.TXT" For Output As #f
        Print #f, .responseText
        Close #f
    End With
    
End Sub
Regards,
Hans

User avatar
sal21
PlatinumLounger
Posts: 4169
Joined: 26 Apr 2010, 17:36

Re: save json resuult in c:\mydir

Post by sal21 »

HansV wrote:
26 Oct 2022, 18:08

Code: Select all

Sub TEST_JSON_PARSE()
    Dim f As Long
    Dim xmlhttp As New MSXML2.XMLHTTP60, myurl As String
    
    myurl = "https://comuni.openapi.it/province/" '//replace with your URL
    
    With xmlhttp
        .Open "GET", myurl, False
        .setRequestHeader "Authorization", "Bearer xxxx"
        .Send
        f = FreeFile
        Open "C:\MyDir\JSON.TXT" For Output As #f
        Print #f, .responseText
        Close #f
    End With
    
End Sub
tks!

plese hide the key!

User avatar
HansV
Administrator
Posts: 75751
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: save json resuult in c:\mydir

Post by HansV »

Done. Please don't post sensitive information such as keys in the future.
Regards,
Hans

User avatar
sal21
PlatinumLounger
Posts: 4169
Joined: 26 Apr 2010, 17:36

Re: save json resuult in c:\mydir

Post by sal21 »

HansV wrote:
26 Oct 2022, 19:37
Done. Please don't post sensitive information such as keys in the future.
:cheers: