IHTSDO / SNOMED-in-5-minutes

Easy-to-use tutorials for accessing SNOMED APIs within 5 min using various programming languages
Other
123 stars 56 forks source link

VBA client side HTTP request, Resource not found #15

Closed AlexanderJohnSalter closed 4 years ago

AlexanderJohnSalter commented 4 years ago

This is quite probably not how the API is intended for use! I am using the API in excel to grab the likely associated snomed terms for a list of locally used terms a few thousand long. it runs fine until I hit 400 terms and then it hangs and errors as "Resource not found" or "Security issue", seems to resolve next day! Is this a same domain policy issue? some other security issue? does the HTTP request require specific headers?

Sub getTerms()

'Dimension variables Dim URL As String Dim edition As String Dim Version As String Dim filtertag As String Dim MyRequest As Object Dim Result As Variant Dim R As Integer Dim c As Variant Dim searchterm As String Dim baseURL As String Dim count As Integer

'set base variables baseURL = "https://browser.ihtsdotools.org/snowstorm/snomed-ct/v2/" edition = "MAIN" Version = "2019-07-31" count = 0

'loop through values to lookup from worksheet lastrow = Cells(Rows.count, "A").End(xlUp).Row

For Each c In Worksheets("API").Range(Cells(2, 1), Cells(lastrow, 1))

If c.Offset(0, 2).Value = "" Then searchterm = c.Value

'compile URL for HTTP request URL = baseURL + edition + "/" + Version + "/concepts?term=" + searchterm + "&conceptActive=true&groupByConcept=true&searchMode=STANDARD&offset=0&limit=50"

'Create request Set MyRequest = CreateObject("MSXML2.XMLHTTP.6.0") MyRequest.Open "GET", URL, False

'submit request MyRequest.send ""

'push result into variable Result Result = MyRequest.ResponseText

'parse results Result = Split(Result, "conceptId")

        For R = 1 To UBound(Result)
            OP = Split(Result(R), "term")

            OP1 = Split(OP(0), """")
                'push SCTID into worksheet
                c.Offset(0, (R * 2)).Value = OP1(2)

            OP2 = Split(OP(1), """")
                'push term into worksheet
                c.Offset(0, (R * 2) + 1).Value = OP2(2)
        Next

End If count = count + 1 Worksheets("API").Cells(1, 2) = count Next End Sub

rorydavidson commented 4 years ago

It could be that you've hit our live server rate limit. That server is made available for reference or development, but not for volume access. We recommend running an instance of the terminology server, snowstorm, if you want to do more intensive queries.

rorydavidson commented 4 years ago

Closing due to inactivity