Guid as a parameter to a service operation RRS feed

  • Question

  • Hi,

    I'm trying to create a service operation that takes a Guid as a parameter but I'm always getting the following exception "Bad Request - Error in query syntax"

    In another thread, it's stated that this is a supported parameter type.

    Is there anthing special I need to do when creating the URL?

    This is the GET URL i'm using http://localhost:55555/WebDataService.svc/GetData()?g=a10c5e9c-b6f3-4bf6-8230-91d6f6785cda

    I've also tried every other combination of URL's I can think of without any luck.

    This is the method:




    public IQueryable<Data> GetData(Guid g)



    var data = from m in this.CurrentDataSource.Data


    select m;


    return data;


    Everything works fine if I change the parameter type to int.



    Thursday, April 16, 2009 3:11 PM


  • Hi Ross,

    There are specific rules for formatting different primitive types in a data service URI.

    You can find them as part of this article, written by Mike Flasko, under the section called "Data Type Literal Representations."

    Using ADO.NET Data Services

    The specific rule for guid's is:

    where each d represents [A-Fa-f0-9]

    NOTE: guid is case insensitive and spaces are not allowed between guid and the quoted portion.

    So your URI above should be replaced with: http://localhost:55555/WebDataService.svc/GetData()?g=guid'a10c5e9c-b6f3-4bf6-8230-91d6f6785cda'

    Let me know if you have any further problems.
    Matt Meehan, ADO.NET Data Services (Astoria)
    Thursday, April 16, 2009 3:43 PM