Error cunsumir a WEB API, HTTP POST

0

I have a problem when consuming an api that I hosted on my IIS server, that is the api, it is a POST method, where it receives two parameters

[Route("api/Documentos/session")]
        [HttpPost]
        public String session(string username, string passoword)
        {
            Respuesta respuesta = new Respuesta();
            try
            {
                passoword = EncryptDecrypt.Encrypt(passoword, EncryptDecrypt.Key);
                passoword = EncryptDecrypt.Decrypt(passoword, EncryptDecrypt.Key);
                if (username.Equals(Configuracion.GetUsername) && passoword.Equals(Configuracion.GetPassword))
                {
                    respuesta.success = Message.Success;
                    respuesta.error = Message.NotError;
                    respuesta.code = Message.CodeSuccess;
                }
                else
                {
                    respuesta.success = Message.NotSucces;
                    respuesta.error = Message.ErrorCredentials;
                    respuesta.code = 0;
                }
            }
            catch (Exception)
            {
                respuesta.success = false;
                respuesta.error = "invalid_request: Connection Failure";
                respuesta.code = 2;
                return JsonConvert.SerializeObject(respuesta);
            }
            return JsonConvert.SerializeObject(respuesta);
        }

And here I have the method where I consume the API, but in the response I get the message that the HTTP resource that matches the url was not found, but when I try it in the POSTAM it works perfect, which can be?

public void GetREST()
            {
                var client = new RestClient("http://localhost:8081/api/Documentos/");
                var request = new RestRequest("session", Method.POST);
                request.Timeout = 300000;
                request.RequestFormat = DataFormat.Json;
                request.AddParameter("username", "profuturo_user", 
                ParameterType.GetOrPost);
                request.AddParameter("passoword", "Anfexi123%%", 
                ParameterType.GetOrPost);
                IRestResponse response = client.Execute(request);
                var content = response.Content;
            }
  

{"Message": "No HTTP resource was found that matches   the URI of the request   ' link '. "," MessageDetail ":" No   no action was found in the 'Documents' driver that matches   with the request. "}

    
asked by Oscar Navarro 30.11.2018 в 20:19
source

0 answers