Loquate API

Ashen

New Member
Joined
Aug 4, 2016
Messages
12
I have a file of data already prepared for running through the API here

and i would REALLY like to do this using VBA, but i have to be honest, it could be because its late and i am tired, but i'm struggling to see how i can send this file [C:\Users\XXXX\Loquate.txt ] to the data cleansing service, and get the results back to either a text file or excel file.... I have a key, and am reasonable with VBA, but none of the googling i have done is giving me a clue....
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Untested, etc. but try this, assuming your Loquate.txt file is in the format shown in the example request:
VBA Code:
Public Sub API_request()

    Dim FSO As Object, httpReq As Object, ts As Object
    
    Set FSO = CreateObject("Scripting.FileSystemObject")
    Set httpReq = CreateObject("MSXML2.XMLHTTP")
    With httpReq
        .Open "POST", "https://api.addressy.com/Cleansing/International/Batch/v1.00/json4.ws", False
        .setRequestHeader "Content-Type", "application/json"
        .send (FSO.OpenTextFile("C:\Users\XXXX\Loquate.txt").ReadAll)
        Set ts = FSO.CreateTextFile("C:\Users\XXXX\Results.txt")
        ts.Write .responseText
        ts.Close
    End With

End Sub
 
Upvote 0
Untested, etc. but try this, assuming your Loquate.txt file is in the format shown in the example request:
VBA Code:
Public Sub API_request()

    Dim FSO As Object, httpReq As Object, ts As Object
   
    Set FSO = CreateObject("Scripting.FileSystemObject")
    Set httpReq = CreateObject("MSXML2.XMLHTTP")
    With httpReq
        .Open "POST", "https://api.addressy.com/Cleansing/International/Batch/v1.00/json4.ws", False
        .setRequestHeader "Content-Type", "application/json"
        .send (FSO.OpenTextFile("C:\Users\XXXX\Loquate.txt").ReadAll)
        Set ts = FSO.CreateTextFile("C:\Users\XXXX\Results.txt")
        ts.Write .responseText
        ts.Close
    End With

End Sub


wow - that looks amazing - thank you so much, just need to check my results - but seriously THANK YOU!
 
Upvote 0

Forum statistics

Threads
1,214,649
Messages
6,120,732
Members
448,987
Latest member
marion_davis

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top