Question
· Dec 19, 2020

REST: Not Supported : "in": "PATH",

I have been using the 

"in": "PATH"

parameter type for at least a year and was working fine for my GET requests.

Now, since this new version, it has stopped compiling. Does someone know why and what's the workaround to make a request like this work

/getmethod/getparam

 

Regards

Product version: IRIS 2020.1
$ZV: IRIS for Windows (x86-64) 2020.1 (Build 215U) Mon Mar 30 2020 20:14:33 EDT
Discussion (7)0
Log in or sign up to continue

This is a sample spec. note this line

"in":"query",
Now I have to call this rest endpoint as 

http://localhost:52774/csp/restapp/Demo?country=uk

however earlier i had
"in":"path"   
and was calling rest endpoint as 

http://localhost:52774/csp/restapp/Demo/uk.

Now in=path does not even compile. Thus just curious why .
----------------------------------------------------------------


XData OpenAPI [ MimeType = application/json ]
{
{
"swagger":"2.0",
"info":{
"title":"O",
"version":"1"
},
"schemes":[
"http",
"https"
],
"consumes":[
"application/json]"
],
"produces":[
"application/json]"
],
"paths":{

"/Demo":{
"get":{
"summary":"Get Demo ",
"description":"Demo ",
"operationId":"GETDemo",
"x-ISC_CORS":true,
"consumes":[
"application/json]",
"text/html]"
],
"produces":[
"application/json]",
"text/html]"
],
"parameters":[
{
"name":"country",
"type":"string",
"in":"query",
"description":"Country Name",
"allowEmptyValue": true
} ],
"responses":{
"200":{
"description":"Returns Country",
"schema": {
"type":"string"
}
}
}
}
}
}
}
}
 

Did you import the Swagger spec or write the code by yourself?

Indeed, "Path" or "query" aproach does make difference inside the Intersystems structure.

Example:

Class REST.Demo Extends %CSP.REST
{ XData UrlMap [ XMLNamespace = "http://www.intersystems.com/urlmap]
{
<Routes>
<Route Url="/Demo/:in" Method="GET" Call="GetPath" Cors="true"/>
<Route Url="/Demo" Method="GET" Call="GetQuery" Cors="true"/>
</Routes>
} ClassMethod GetPath(in As %String) As %Status
{
Set outJSON = ##class(%ZEN.proxyObject).%New()
Set outJSON.in = in
Write outJSON.%ToJSON()
Quit $$$OK
} ClassMethod GetQuery(
pInput As %Library.AbstractStream,
Output pOutput As %Stream.Object) As %Status
{
Set outJSON = ##class(%ZEN.proxyObject).%New()
Set outJSON.Country = $Get( %request.Data( "Country", "1") )
Write outJSON.%ToJSON()
Quit $$$OK
} }
 

I took the spec. from your reply to Dmitriy's question, changed "query" to "path", smooshed it into one line, then pasted it into a terminal:

USER>s swagger={...}

USER>s status=##class(%REST.API).CreateApplication("neerav",swagger)

USER>zw status
... /* ERROR #8722: Path parameter country is not used in url /Demo of route with GETDemo in class: neerav.spec

I then changed "/Demo" to "/Demo/{country}":

USER>s swagger={ "swagger":"2.0","info":{ "title":"O","version":"1" },"schemes":["http","https"],"consumes":["application/json]"],"produces":["application/json]"],"paths":{ "/Demo/{country}":{ "get":{ "summary":"Get Demo ","description":"Demo ","operationId":"GETDemo","x-ISC_CORS":true,"consumes":["application/json]","text/html]"],"produces":["application/json]","text/html]"],"parameters":[{ "name":"country","type":"string","in":"path","description":"Country Name","allowEmptyValue": true } ],"responses":{ "200":{ "description":"Returns Country","schema": { "type":"string" } } } } } } }

USER>s status=##class(%REST.API).CreateApplication("neerav",swagger)

USER>zw status
status=1

I'm curious to know in what version this previously worked. I get the same error in 2019.1.2.