Question
· Sep 14, 2018

How do I process queryString parameters in a HttpGet Request in a %CSP.REST page?

So by queryString I mean name-value pairs passed  in as part of the URL. Currently my service works when called like this
http://{{SERVER}}:{{PORT}}/bsolabs/api/codemanagement/testcode/BIO/CRP

What would I need to change so I can call it like this?
http://{{SERVER}}:{{PORT}}/bsolabs/api/codemanagement/testcode?Discipline=BIO&TestCode=CRP

Discussion (2)0
Log in or sign up to continue

Class Rest.EmailSvc Extends %CSP.REST
{

XData UrlMap [ XMLNamespace = "http://www.intersystems.com/urlmap" ]
{
<Routes>
    <Route Url="/TesteQuery/" Method="GET" Call="TesteQueryString"/>
</Routes>
}

ClassMethod TesteQueryString() As %Status
{
    Set tSC = $$$OK
    
    If 'tSC Quit tSC       
    Set tProxy = ##class(%ZEN.proxyObject).%New()
    Set tProxy.Discipline = $Get(%request.Data("Discipline", 1))
    Set tProxy.TestCode = $Get(%request.Data("TestCode", 1))
    
    Set %response.ContentType = "application/json"
    set %response.Status = 200
    Do tProxy.%ToJSON()
    
    Quit tSC
}

}