Need help with simple rest plugin
I'm trying to create a basic REST plugin with some additional information we need and I'm struggling to get it to work. I started with the instructions here (http://confluence.jetbrains.com/display/TW/REST+API+Plugin#RESTAPIPlugin-Developmentlinks). I basically copy and pasted CCTrayRequest into my own request class. I've got it packaged and TC appears to be loading it. I can hit basic paths (like "/servers") under my plugin's api path but I can't hit my request class specifically.
The zip file is attached (libs removed for size). Any help would be greatly appreciated!
Attachment(s):
TeamCityStalker.Plugin.zip
Please sign in to leave a comment.
Hi TIm,
It's great that you are writing a new plugin! If you want to share details as to what it should do, you are welcome.
The plugin works for me for URL "/app/tcstalker/main/status" which is what you defined in TcStalkerRequest.
It does not display in the browser as you need to set correct content-type (e.g. use" @Produces("text/plain")" to the method)
Note "Hallo world!" inthe response:
C:\>curl -v http://localhost:8111/app/tcstalker/main/status -u myUser:myPassword
* About to connect() to localhost port 8111 (#0)
* Trying 127.0.0.1...
* connected
* Connected to localhost (127.0.0.1) port 8111 (#0)
* Server auth using Basic with user 'admin'
> GET /app/tcstalker/main/status HTTP/1.1
> Authorization: Basic XXX=
> User-Agent: curl/7.26.0
> Host: localhost:8111
> Accept: */*
>
< HTTP/1.1 200 OK
< Server: Apache-Coyote/1.1
< Set-Cookie: TCSESSIONID=C4EE8273B041CB24D047AA3BB8DF251E; Path=/; HttpOnly
< Set-Cookie: RememberMe=""; Expires=Thu, 01-Jan-1970 00:00:10 GMT; Path=/; HttpOnly
< Pragma: no-cache
< Expires: Thu, 01 Jan 1970 00:00:00 GMT
< Cache-Control: no-cache
< Cache-Control: no-store
< Content-Type: application/xml
< Transfer-Encoding: chunked
< Date: Thu, 24 Oct 2013 10:25:08 GMT
<
Hello world!* Connection #0 to host localhost left intact
* Closing connection #0
Dang, I knew it was something dumb! Thanks a lot, Yegor!!
One more question, how do I make so my plugin doesn't require authentication?
Ugh, nevermind. I didn't have guest auth enabled!
You can check example code: /jetbrains/buildServer/server/rest/APIController.java:155 (APIController.registerController)