How to send a GUID to a web api webservice
asp.net-web-api, guid
Solution
I suppose that you are using the default route in which the pattern is:
api/{controller}/{id}
So try naming your parameter accordingly:
public TextsController: ApiController
{
public HttpResponseMessage Get(Guid? id)
{
...
}
}
Now the `/api/texts/2ADEA345-7F7A-4313-87AE-F05E8B2DE678` url should hit the `Get` action on the `TextsController` and populate the `id` parameter.
Problem
I am extending `ApiController` for a webservice. The service takes a GUID as its only parameter. This is the url that I type in ``` /api/texts/2ADEA345-7F7A-4313-87AE-F05E8B2DE678 ``` However, the Guid never reaches the `Get` method. If I set it to object ``` public Object Get(Object userId) ``` the method fires, but userid is null. If i set it to guid ``` public Object Get(Guid? userId) ``` I get the error No action was found on the controller 'texts' that matches the request. Does anyone have a sample that could help me?