Reputation: 479
I am making API-calls to a server from Excel VBA by using this JsonConverter:
*) https://github.com/VBA-tools/VBA-JSON/blob/master/JsonConverter.bas
I use this commands which works fine:
http.Open "GET", APIString, False
http.send
Set JSON = ParseJson(http.responseText)
Although in some cases the received JSON-string is corrupt and my code stops with an error.
If I am correct, there should be a 'http-header' containing a number which indicates the JSON-string is corrupt.
Do you know where and how I can import this 'http-header' from Excel VBA. In that case I could cancel my API-call in those cases the number in the header indicates the content is corrupt.
Thanks!
Upvotes: 0
Views: 1032
Reputation: 29296
Check the status of your http-request:
if http.Status = 200 Then
Set JSON = ParseJson(http.responseText)
else
' ... (error handling)
end if
Upvotes: 2