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
Could you explain your issue with some examples of code?
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 .
----------------------------------------------------------------
{
{
"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:
{ 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
} }
For a "path" parameter, there has to be a corresponding placeholder in the path string. I got this to work with "path" instead of "query" by changing "/Demo" to "/Demo/{country}", which generated a "/Demo/:country" route in the URL map.
Can you please paste the openapi spec for that ?
Another factor which I forgot to mention was that the Path was working past 2 years with the openapi spec I had, it only stopped working on the latest 2020 version.
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:
I then changed "/Demo" to "/Demo/{country}":
I'm curious to know in what version this previously worked. I get the same error in 2019.1.2.
It used to work on IRIS 2019.. Now I don't remember what version of 2019. I think it was 2019.1.1 but can't bet on it.
Social networks
InterSystems resources
Log in or sign up
Log in or create a new account to continue
Log in or sign up
Log in or create a new account to continue
Log in or sign up
Log in or create a new account to continue