虽然我有一个令牌,但xamarin给出了401错误,这是个问题

时间:2020-05-20 20:41:43

标签: xamarin token crud solution restapi

虽然,我有一个令牌,当我发布休息的api或获取时,xamarin会给出401错误。您有任何解决方案吗?

 public async Task<List<Gorev>> GetGorevlerAsync(Gorev Gorev, string accessToken)
    {
        var client = new HttpClient();
        client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
        var json = JsonConvert.SerializeObject(Gorev);
        HttpContent content = new StringContent(json);
        content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
        string uri = Constants.BaseApiAddress + "http/GorevTeamLstStored";
        var ReturnJson = await client.PostAsync(uri, content);

        var ls = ReturnJson.Content.ReadAsStringAsync().Result;

        var Gorevler = JsonConvert.DeserializeObject<List<Gorev>>(ls);
        return Gorevler;
       .
    }

0 个答案:

没有答案