This project is read-only.

405 Method Not Allowed

Jun 24, 2013 at 7:39 AM
Hi Guys,
Things are going great now and thanks again for all your help before.
I am now just trying to create and use a Restful Objects API of my code.
I am creating a restful API as I need to have a link in an email that a user can click to execute an action of one of my repositories.
However I am getting a 405 error Method Not allowed.

I am using postman with google chrome.
http://localhost:17007/domain-types/Lansw.Uwas.Model.WorkItemRepository/actions/FindAvailableWorkItemByID?workItemId=1

This repository is one of my menu item repositories and there is no authorisation or security checks on this repository.
Can you help me please?
Regards,
          Alistair
Jun 24, 2013 at 10:05 AM
This isn't a valid RO url:

http://localhost:17007/domain-types/Lansw.Uwas.Model.WorkItemRepository/actions/FindAvailableWorkItemByID?workItemId=1

The first part of yourURL 'domain-types' indicates that you are looking for domain-type information (i.e. the metadata) - which would be unusual anyway. The last part suggests you are trying to do something (though even that isn't right as there is no 'invoke').

I assume you have just constructed this URL by hand - and got mixed up between ideas. If you are going to construct a URL by hand then have the Restful Objects specification printed out and to hand, and use that as the guide.

But more importantly, RO is fully HATEOUS - meaning that you shouldn't ever have to 'make up a URL' - you can use the whole application by following links from the home resource. This is far safer than trying to make up the URL.

If you haven't read the RO spec - I recommend that you read it thoroughly.
Jun 24, 2013 at 10:20 AM
Thanks Richard,
                           But no I didn't write this URL by hand except by cutting and pasting. And yes I have read read the doco.
I just dont see how to pass parameters to the rest call.

Here is the full listing of the Rest interface generated (for the method that I want to use) in google chrome when I run the rest client.
I can see there is an invoke method but how do I pass a parameter to it? I didn't see anything in the doco about how to do that.
{
id: "ApproveWorkItemByID",
parameters: {
workItemId: {
links: [
{
rel: "describedby",
method: "GET",
type: "application/json; profile="urn:org.restfulobjects:repr-types/action-param-description"; charset=utf-8",
href: "http://localhost:17007/domain-types/Lansw.Uwas.Model.WorkItemRepository/actions/ApproveWorkItemByID/params/workItemId"
}
],
extensions: { }
}
},
extensions: { },
links: [
{
rel: "self",
method: "GET",
type: "application/json; profile="urn:org.restfulobjects:repr-types/object-action"; charset=utf-8",
href: "http://localhost:17007/services/Lansw.Uwas.Model.WorkItemRepository/actions/ApproveWorkItemByID"
},
{
rel: "up",
method: "GET",
type: "application/json; profile="urn:org.restfulobjects:repr-types/object"; charset=utf-8; x-ro-domain-type="http://localhost:17007/domain-types/Lansw.Uwas.Model.WorkItemRepository"",
href: "http://localhost:17007/services/Lansw.Uwas.Model.WorkItemRepository"
},
{
arguments: {
workItemId: {
value: null
}
},
rel: "urn:org.restfulobjects:rels/invoke;action="ApproveWorkItemByID"",
method: "PUT",
type: "application/json; profile="urn:org.restfulobjects:repr-types/action-result"; charset=utf-8",
href: "http://localhost:17007/services/Lansw.Uwas.Model.WorkItemRepository/actions/ApproveWorkItemByID/invoke"
},
{
rel: "describedby",
method: "GET",
type: "application/json; profile="urn:org.restfulobjects:repr-types/action-description"; charset=utf-8",
href: "http://localhost:17007/domain-types/Lansw.Uwas.Model.WorkItemRepository/actions/ApproveWorkItemByID"
},
{
id: "workItemId",
rel: "urn:org.restfulobjects:rels/action-param",
method: "GET",
type: "application/json; profile="urn:org.restfulobjects:repr-types/action-param-description"; charset=utf-8",
href: "http://localhost:17007/domain-types/Lansw.Uwas.Model.WorkItemRepository/actions/ApproveWorkItemByID/params/workItemId"
}
]
}
Jun 24, 2013 at 11:56 AM
Edited Jun 24, 2013 at 11:57 AM
Then you've followed the wrong link. As I said earlier, the 'domain-types' indicates you are looking at the metadata resources, not the model itself. I think the link you meant to follow is:

http://localhost:17007/services/Lansw.Uwas.Model.WorkItemRepository/actions/ApproveWorkItemByID/invoke

I note from your listing that this particular method must be invoked with a PUT, not a GET - I assume that means you marked the method {Idempotent] which sounds correct. I can't recall - I'm out of office - if you can add a query string on a PUT - I think the answer is no. IN which case you must supply the params as a JSON body, the format of which is provided for you in the details of the invoke link ie.:
{
workItemId: {
value: 1
}
Jun 25, 2013 at 5:10 AM
Dear Richard,
                    Awesome! Thanks mate this worked and really quick to!
http://localhost:17007/services/Lansw.Uwas.Model.WorkItemRepository/actions/ApproveWorkItemByID/invoke

The request header has
Content-Type
application/x-www-form-urlencoded


with the body containing

{
workItemId: {
value: 1
}
}

The result shows
Status Code: 200 OK
Cache-Control: no-cache
Content-Length: 318
Content-Type: application/json; profile="urn:org.restfulobjects:repr-types/action-result"; charset=utf-8; x-ro-domain-type="http://loc alhost:17007/domain-types/boolean"
Date: Tue, 25 Jun 2013 00:59:11 GMT
Expires: Tue, 25 Jun 2013 00:59:11 GMT
Pragma: no-cache
Server: Microsoft-IIS/8.0
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
X-SourceFiles: =?UTF-8?B?RDpcTGFuc3cuVXdhcy5SZXN0QVBJXExhbnN3LlV3YXMuUmVzdEFQSVxzZXJ2aWNlc1xMYW5zdy5Vd2FzLk1vZGVsLldvcmtJdGVtUmVwb3NpdG 9yeVxhY3Rpb25zXEFwcHJvdmVXb3JrSXRlbUJ5SURcaW52b2tl?=