VBA Accessing GZIP JSON Response - Characters are garbled

manofcheese

New Member
Joined
Jan 5, 2019
Messages
8
I am trying to access an api from a site called keepa.com. I create a Msxml2.ServerXMLHTTP object and am able to get a response but the text is just a jumbled mess. For example the some of the response looks like this :
?x^??^H?\KIv3K ,+)?j2?%b6??;????u?iL\i??4???k}?:?I???]??????k??????1?????%}?WC????u??=S???Ï?????/f*??Zn=?+h?????i?r?^?L`????kJ??`lim&2?MF??V

I have tried to use MSXML2.XMLHTTP instead but I get an error saying that access is denied.

Below is my current code.

Code:
Function getProductObject(apiKey As String, asins As String) As Object
    
    Dim url As String
    url = "http://api.keepa.com/product?key=" & apiKey & "&domain=1&asin=B06XRT2B3P,B06XKLHSWJ&history=1&stats=1"
    
    Dim hReq As Object
    Set hReq = CreateObject("Msxml2.ServerXMLHTTP")


    With hReq
        .Open "GET", url, False
        .Send
    End With
    
    Debug.Print hReq.ResponseText
        
    Dim response As String
    response = "{""data"":" & hReq.ResponseText & "}"
    
    Set getProductObject = JsonConverter.ParseJson(response)


End Function

Does anyone know what I need to do to get the response back in readable text?
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
are you looking at a zip file, they will be highly compressed so would need a decompressor to see the stored items
 
Upvote 0
I've never worked with compressing and decompressing files before. I've tried to change the request header to request the file as decompressed but it didn't seem to work. Do you have any suggestions on a decompressor to use and how to use it?
 
Upvote 0
Thanks John. I just tested both of those and it looks like they do ignore this header line. Do you have any ideas on other ways of decompressing? My Googling abilities are failing me on this.
 
Upvote 0
Just use msxml2.xmlhttp instead of msxml2.serverxmlhttp. Or is there a reason you’re using the server version?
 
Upvote 0
You freakin' rock. I thought I had already checked that but I guess I missed it. Now it comes in just fine. Thank you so much!
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,178
Members
453,021
Latest member
Justyna P

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