REST POST 405 error
I'm testing out the new %CSP.REST way of creating an api and having a problem with a POST getting a 405 error.
I get data returned when I do a GET, so I don't think it's a configuration issue or a class issue.
I have no problem with %CSP.Page when creating a REST type method. So what am I missing?
Can someone give me some advice?
Thank you.
Please consider showing some code.
Here is what I'm trying right now just to check if the POST code is working or making it to the method.
The Route:
The Method:
{
Set tSC=$$$OK
W "test...",!
Quit tSC
}
This GET works:
How do I allow a method then with %CSP.REST?
You need to add POST route:
Hi, it's still not clear. Do I have to define both a GET and POST for the same Route?
Is that what I'm missing?
Hi.
rror 405 refers to method not allowed.
Probably this being invoked a method that only supports GET as a POST.
Yes.
Usually they have different logic so it makes more sense. What's your use case for GET and POST handlers to be the same?
Hi,
Use this Example code
Class Rest.UsuarioSvc Extends %CSP.REST
{
XData UrlMap [ XMLNamespace = "http://www.intersystems.com/urlmap" ]
{
<Routes>
<Route Url="/Oi/:xpto" Method="GET" Call="Oi"/>
</Routes>
}
ClassMethod Oi(xpto As %String) As %Status
{
Set tSC = $$$OK
If 'tSC Quit tSC
Set tProxy = ##class(%ZEN.proxyObject).%New()
Set tProxy.Oi = xpto _ "1234"
Set %response.ContentType = "application/json"
set %response.Status = 200
Do tProxy.%ToJSON()
Quit tSC
}
}
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