GauravGupta-1893 avatar image
0 Votes"
GauravGupta-1893 asked ·

Returning value from resful webapi and redirecting to another page - problem

I am returning a response from a restful api and passing on returned value to another webapi. Following is code private async void ButtonLogin_Clicked(object sender, EventArgs e) { var result = SendSMS.SendOTP(TxtMobileNo.Text); //Line 1 OTP_Session = ((SMSResponse)result.Result).Details.ToString(); // Line 2 await Shell.Current.GoToAsync($"otpverification?mobileno={TxtMobileNo.Text}&otpsession={OTP_Session}"); /Line 3 } Code in the line 3 is not getting executed... i dont know whats the problem. Anyone can please help where i am wrong. Following is the SendOTP Function public static async Task<SMSResponse> SendOTP(string mobileNo) { string webserviceurl = "" + api_key + "/SMS/" + mobileNo + "/AUTOGEN"; var httpclient = new HttpClient(); var json = JsonConvert.SerializeObject(mobileNo); HttpContent httpContent = new StringContent(json); httpContent.Headers.ContentType = new MediaTypeHeaderValue("application/json"); HttpResponseMessage response = await httpclient.PostAsync(webserviceurl, httpContent); HttpContent responseContent = response.Content; string result = await response.Content.ReadAsStringAsync(); SMSResponse objSMSResponse = new SMSResponse(); using (var reader = new System.IO.StreamReader(await responseContent.ReadAsStreamAsync())) { var content = await response.Content.ReadAsStringAsync(); objSMSResponse = JsonConvert.DeserializeObject<SMSResponse>(content); } return await Task.FromResult( objSMSResponse); } Following is SMSResponse Class public class SMSResponse { public string Status { get; set; } public string Details { get; set; } }

· 1
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @GauravGupta-1893 , could you please post the error log about this problem which will help us to address the problem? Also, can you format your code so that we can review your code more easily?

0 Votes 0 ·

0 Answers