0
Answered
Валерия 4 months ago in Подсказки • updated by Антон 4 months ago 6

Проблема из письма:

Vba access msxml2.Xmlhttp
Post

Readystate 4
А status = 12004

Answer

Answer

А если сделать синхронный запрос, какой будет результат?

xhr.Open "POST", "https://suggestions.dadata.ru/suggestions/api/4_1/rs/suggest/address", False
xhr.setRequestHeader "Content-Type", "application/json;charset=UTF-8"
xhr.setRequestHeader "Accept", "application/xml"
xhr.setRequestHeader "Authorization", "Token " & Token
xhr.send "{ ""query"": """ & strQuery & """ }"   
GetAdrData = xhr.responseText
xhr.Open "POST", "https://suggestions.dadata.ru/suggestions/api/4_1/rs/suggest/address", True
    xhr.setRequestHeader "Content-Type", "application/json;charset=UTF-8"
    xhr.setRequestHeader "Accept", "application/xml"
    xhr.setRequestHeader "Authorization", "Token " & Token
    xhr.send "{ ""query"": """ & strQuery & """ }"
Dim t As Date
    t = Time
    frm.SetQueryStatus 100
   
    While DateDiff("s", t, Time) < 20 And xhr.ReadyState = 1
        frm.SetQueryStatus 100
        If boolStop Then GoTo Wend_
        DoEvents
    Wend
    frm.SetQueryStatus xhr.Status
Wend_:
   
    GetAdrData = xhr.responseText
Answer

А если сделать синхронный запрос, какой будет результат?

xhr.Open "POST", "https://suggestions.dadata.ru/suggestions/api/4_1/rs/suggest/address", False
xhr.setRequestHeader "Content-Type", "application/json;charset=UTF-8"
xhr.setRequestHeader "Accept", "application/xml"
xhr.setRequestHeader "Authorization", "Token " & Token
xhr.send "{ ""query"": """ & strQuery & """ }"   
GetAdrData = xhr.responseText

Если запрос синхронный, то ошибка получения данных

Можете написать код и точный текст ошибки?