none
WCF URITemplate RRS feed

  • Question

  • I am new to learn the WCF Rest service, if I create a WCF application from the Visual Studio, and use a int parameter, but it show me a error, say that I need to use the string parameter, so can we use the int parameter?
    Thursday, March 3, 2016 3:01 AM

Answers

  • The Web is HTTP string. Restful is string.

    So, the int parm has to be passed a string data and converted back to int in the rest method

    Method(string id)

    {

    int intid = (int)id;

    }

    Thursday, March 3, 2016 4:05 AM
  • Hello,

    The @DA924x has showed a workaround for your issue. It will work for you.
    The other workaround is that we can modify the UriTemplate as following:

    [OperationContract]
    [WebGet(UriTemplate = "Test/?id={id}")]
    string MethodName(int id);
    Best Regards,
    Amy Peng

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Friday, March 4, 2016 9:24 AM
    Moderator

All replies

  • The Web is HTTP string. Restful is string.

    So, the int parm has to be passed a string data and converted back to int in the rest method

    Method(string id)

    {

    int intid = (int)id;

    }

    Thursday, March 3, 2016 4:05 AM
  • Hello,

    The @DA924x has showed a workaround for your issue. It will work for you.
    The other workaround is that we can modify the UriTemplate as following:

    [OperationContract]
    [WebGet(UriTemplate = "Test/?id={id}")]
    string MethodName(int id);
    Best Regards,
    Amy Peng

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Friday, March 4, 2016 9:24 AM
    Moderator