2

One of the API calling from outside company to our use the parameter name "ref". They asking us to create the web api which accept this parameter. We are writing in C# Web Api and "ref" is a keyword and wont able to do that. Any work around?

https://xxxxxxxxx/xxx/xxx/xxxxx/?ref=1234

Sachu
  • 7,555
  • 7
  • 55
  • 94

2 Answers2

4

You can accept ref as a parameter using@ symbol in front of your field:

public JsonResult MyMethod(string @ref)

You can read more here

Rahul Sharma
  • 7,768
  • 2
  • 28
  • 54
2

You can also use the Name property of FromUriAttribute:

public JsonResult MyMethod([FromUri(Name = "ref")] string reference)
vc 74
  • 37,131
  • 7
  • 73
  • 89