Click here to Skip to main content
15,867,771 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I'm connecting the windows program with the same api, but Xamarin doesn't take action even if I give you the same address. Example(api.xxx.com/api/Users/GetAll)
Thank you if you can help.

What I have tried:

C#
private string Url = "api.xxx.com/api/Users/";

private async Task<HttpClient> GetClient()
       {
           HttpClient client = new HttpClient();
           client.DefaultRequestHeaders.Add("Accept", "application/json");
           return client;
       }

 private async Task<MobileResult> Process(ViUserModel viUserModel,
           string processType)
       {
           HttpClient client = await GetClient();
           // Insert işlemini gerçekleştirdik.
           var response = await client.PostAsync(Url + processType,
               new StringContent(JsonConvert.SerializeObject(viUserModel),
               Encoding.UTF8, "application/json"));

           var mobileResult = await response.Content.ReadAsStringAsync();

           // Insert işleminin cevabını alıyoruz...
           var result = JsonConvert.DeserializeObject<MobileResult>(mobileResult);
           return result;
       }

public async Task<MobileResult> GetAll(ViUserModel viUserModel, string keyCode)
       {
           return await Process(viUserModel, "GetAll?keyCode=" + keyCode);
       }
Posted
Updated 30-Aug-20 2:29am
v3
Comments
Sandeep Mewara 30-Aug-20 10:00am    
What does the debugger say?
Smthm 30-Aug-20 10:01am    
Not giving errors
Dave Kreskowiak 30-Aug-20 11:25am    
The debugger is not there to tell you what the errors are. It's there to debug YOU and YOUR UNDERSTANDING of the code and how it executes.

Set breakpoints and execute the code line-by-line, examining the contents of variables after each line. Changes are really high the code knows something about the content of variables that you don't.
Smthm 30-Aug-20 13:54pm    
return await Process(viUserModel, "GetAll?keyCode=" + keyCode);
It's not doing anything here.the process is acting as if it's done
Dave Kreskowiak 30-Aug-20 15:33pm    
Set a breakpoint at the start of the Process method to see what it's doing.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900