Saturday, 17 August 2013

Calling ServiceStack with backslash in request data

Calling ServiceStack with backslash in request data

I am calling a service stack api from VB.NET that I've created - It
essentially looks up the default language spoken as you pass the
nationality of a person.
Dim response As BindingList(Of
Symphony_SystemFunctionsDefaultLanguageResponse)
Dim client As New JsonServiceClient(BASEURI)
response = client.[Get](New Symphony_SystemFunctionsDefaultLanguage()
With {.NationalityCode = strNationality})
strNationality is a code from a database called "ME/Kuw" (Kuwaiti which
would return Arabic"
Any code that does not have a "/" or a "\" in it returns correctly so I
know the service and calls work however if I use a code ie . "ME/Kuw" I
get a service not found - its sort of interpreting the / as a route, I've
tried making the string URLencoded , but its the same issue.
This is my service and response code - which works fine as long as no "/"
is in the .NationalityCode.
<Route("/SystemFunctions/DefaultLanguage/{NationalityCode}", "GET")>
Public Class Symphony_SystemFunctionsDefaultLanguage
Implements IReturn(Of BindingList(Of
ymphony_SystemFunctionsDefaultLanguageResponse))
Private mvarNationalityCode As String
Public Property NationalityCode() As String
Get
NationalityCode = mvarNationalityCode
End Get
Set(ByVal Value As String)
mvarNationalityCode = Value
End Set
End Property
End Class
Public Class Symphony_SystemFunctionsDefaultLanguageResponse
Private mvarDefaultLanguage As String
Public Property DefaultLanguage() As String
Get
DefaultLanguage = mvarDefaultLanguage
End Get
Set(ByVal Value As String)
mvarDefaultLanguage = Value
End Set
End Property
End Class
and my class that gets the data.
public Class Symphony_SystemFunctionsService
Inherits Service Public Function [get](request As
Symphony_SystemFunctionsDefaultLanguage) As Object
Using dbcontext As New EntitiesModel1
Dim sqlQueryString As String = "proc_s_GetDefaultLanguage '" &
request.NationalityCode & "'"
Dim response As IEnumerable(Of
Symphony_SystemFunctionsDefaultLanguageResponse) =
dbcontext.ExecuteQuery(Of
Symphony_SystemFunctionsDefaultLanguageResponse)(sqlQueryString)
Return response
End Using
End Function
End Class
Any suggestions how I might call this and allow the passing of "/" in that
data?

No comments:

Post a Comment