0

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!

1 Answer 1

2

Check the status of your http-request:

if http.Status = 200 Then
    Set JSON = ParseJson(http.responseText)
else
    ' ... (error handling)
end if
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you Thomas, I will add these lines.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.