Need help - After update from 106.12

37 views
Skip to first unread message

Mahesh Rathi

unread,
Feb 20, 2024, 11:04:06 AMFeb 20
to RestSharp
Greetings!

I was using below code and it worked fine until the 106.12 version of RestSharp. 
 Dim restClient = New RestClient(ymAPIEndPoint)
 restClient.Timeout = -1
 Dim jObjectbody As JObject = New JObject()
 jObjectbody.Add("ClientID", YMClientID)
 jObjectbody.Add("Username", YMUsername)
 jObjectbody.Add("Password", YMPassword)
 jObjectbody.Add("UserType", "Admin")
 Dim restRequest As RestRequest = New RestRequest("Authenticate", Method.POST)
 restRequest.AddParameter("application/json", jObjectbody, ParameterType.RequestBody)
 Dim restResponse As IRestResponse = restClient.Execute(restRequest)
 Dim response As JObject = JObject.Parse(restResponse.Content)

However, after updating the Restsharp library - the IRestResponse is not defined. I changed my code to: 
Dim restClient = New RestClient(ymAPIEndPoint)
Dim jObjectbody As JObject = New JObject()
jObjectbody.Add("ClientID", YMClientID)
jObjectbody.Add("Username", YMUsername)
jObjectbody.Add("Password", YMPassword)
jObjectbody.Add("UserType", "Admin")
Dim restRequest As RestRequest = New RestRequest("Authenticate", Method.Post)
restRequest.AddParameter("application/json", jObjectbody, ParameterType.RequestBody)
Dim restResponse As RestResponse = Await restClient.ExecuteAsync(restRequest)
Dim response As JObject = JObject.Parse(restResponse.Content)

However, the response gives error. With the first code snippet with version 106.12 - no issues. With the updated version, error received is:
{"ClientID":0,"MemberID":0,"FailedLoginReason":"None","ResponseStatus":{"ErrorCode":"Predicate","Message":"The User Type value is required and must be member or admin.","Errors":[{"ErrorCode":"Predicate","FieldName":"UserType","Message":"The User Type value is required and must be member or admin.","Meta":{"PropertyName":"User Type","PropertyValue":"0"}}]}}

Any help would be greatly appreciated.

Thanks!
Reply all
Reply to author
Forward
0 new messages