# Http 405 method not allowed error calling a webservice

**URL:** <https://www.ruby-forum.com/t/http-405-method-not-allowed-error-calling-a-webservice/138393>\
**Category:** Rails\
**Created:** [May 22, 2008, 3:59pm UTC](https://www.ruby-forum.com/t/http-405-method-not-allowed-error-calling-a-webservice/138393 "2008-05-22T15:59:26Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rey9999](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/8e8cbc/32.png) [@Rey9999](https://www.ruby-forum.com/u/Rey9999)\
**Post date:** [May 22, 2008, 3:59pm UTC](https://www.ruby-forum.com/t/http-405-method-not-allowed-error-calling-a-webservice/138393/1 "2008-05-22T15:59:26Z")

</div>

Hello everyone,

I am experiencing some difficulties with a web service I’m creating.

This webservice has a login method which checks some credentials  
against an user database. Everything works beautifully so far.  
Now I’m trying to add a method which creates an instance of an object  
(which, incidentally, belongs\_to an user).  
So i added the following to my api and service definition:

class MywsApi \< ActionWebService::API::Base

inflect\_names false  
api\_method :login, :expects =\> [[:string]], :returns =\> [[:int] ]  
api\_method :newThing, :expects =\> [[:string]], :returns =\> [:int] #\<-  
added this line

end

class MywsService \< ActionWebService::Base  
web\_service\_api MywsApi

def login(name, password)

#does stuff to authenticate  
end

def newThing(session\_id, param1, param2) #\<-Added this method

@user = User.find(session\_id)  
@thing= @user.things.build({:user =\> @user, :field1 =\>  
param1, :field2=\> param2})  
if @thing.save  
return 0  
else  
return 1  
end  
end

end

The login method works perfectly, but when I fire the newThing event I  
receive a most saddening:  
“http 405: method not allowed”.

Am I missing something? do I need to add anything elsewhere to get  
another method working?  
Any help would be immensely appreciated.

Thanks in advance.

Regards,  
Rey9999

---

<div class="post-metadata">

**Author:** ![Rey9999](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/8e8cbc/32.png) [@Rey9999](https://www.ruby-forum.com/u/Rey9999)\
**Post date:** [May 23, 2008, 10:30am UTC](https://www.ruby-forum.com/t/http-405-method-not-allowed-error-calling-a-webservice/138393/2 "2008-05-23T10:30:14Z")

</div>

My bad… I was calling the service on the wrong port.  
As always, all work and no sleep make Rey9999 go blind.
