0

I building a register service in xamarin forms but i get the message "missused header" when i do it in postman it works perfectly, i don't know if i'm missing something when i add the headers, could you help me please

public async Task<UserInfo> postUserCreate(CompletarUsuario usuario)
        {

            var oauthToken = SecureStorage.GetAsync("token");
            CompletarUsuario logintest = new CompletarUsuario();
            string token = string.Format("Bearer {0}", oauthToken);

            var jsonObj = JsonConvert.SerializeObject(logintest);
            using (HttpClient client = new HttpClient())
            {
                StringContent content = new StringContent(jsonObj.ToString(), Encoding.UTF8, "application/json");

                var request = new HttpRequestMessage()

                {

                    RequestUri = new Uri("https://www.phixser.com/utravel/wp-json/wc/v3/customers/"),
                    Method = HttpMethod.Post,
                    Content = content

                };
                request.Headers.Add("Content-Type", "application/json");
                request.Headers.Add("Authorization", "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwczpcL1wvd3d3LnBoaXhzZXIuY29tXC91dHJhdmVsIiwiaWF0IjoxNTc4NTg4Mjg1LCJuYmYiOjE1Nzg1ODgyODUsImV4cCI6MTU3OTE5MzA4NSwiZGF0YSI6eyJ1c2VyIjp7ImlkIjoiMSJ9fX0.GvpqFxBHoVH4NnbPC1HI6G5iP9ojxqMmstucdj4791o");


                var response = await client.SendAsync(request).ConfigureAwait(false);
                string dataResult = response.Content.ReadAsStringAsync().Result;
                UserInfo result = JsonConvert.DeserializeObject<UserInfo>(dataResult);
                return result;
            }

        }

0 Answers0