How to consume https json with webform asp.net c #?

1

Good I would like you to help me I am wanting to consume a service HTTPS . Realizing with asp.net webform. For which I am doing with jquery json I have been reading the documentation and it indicates that you have to use JSONP.

link

What I want is to extract the data thrown by that json and put it in an input.

This is the information that I throw and would like to extract.

Why I've used this is my code.

 <script type="text/javascript">
        function getProducts() {
            var url = "https://www.sentinelconsultagratuita.com/wsrest/Rest/Rws_evalcredit?Usuario=********&Password=********&Servicio=188714&TipoDoc=D&NroDoc=43400262"
             $.getJSON(url, {
                tags: "mount rainier",
                tagmode: "any",
                format: "jsonp"
            })
            .done(function (data) {
                      console.log(data);
                    $('#products').empty();
                    $.each(data, function (key, val) {

                        var row = '<td>' + val.Resultado + '</td><td>' + val.Resultado + '</td>';
                        $('<tr/>', { html: row })
                            .appendTo($('#products'));
                    });
                  });

        }

        $(document).ready(getProducts);
</script>

I get an error.

Using Libreris Restshar.

link

 var client = new RestClient("https://www.sentinelconsultagratuita.com/wsrest/Rest/Rws_evalcredit");
  var request = new RestRequest("resource/{id}", Method.POST);
            request.AddParameter("Usuario", "*********"); 
            request.AddParameter("Password", "********");
            request.AddParameter("Servicio", "188714");
            request.AddParameter("TipoDoc", "D");
            request.AddParameter("NroDoc", "43400262");
  IRestResponse response = client.Execute(request);
 var content = response.Content; 
 TextBox1.Text = response.Content;

I get blank what I want to extract in my texbox1

    
asked by PieroDev 09.08.2018 в 18:24
source

1 answer

2

Here the solution, EYE, before applying the answer start debugging a while so you see why you do not get the code you have, see if the EndPoint is correct, see if the server gives an error and ask the question key "Why?".

I leave you with the task to investigate the difference between: AddBody and AddParameter .

var client = new RestClient("https://www.sentinelconsultagratuita.com/wsrest/Rest/Rws_evalcredit");
var request = new RestRequest(Method.POST);
request.RequestFormat = DataFormat.Json;
request.AddBody(new {
    Usuario = "******",
    Password = "*****",
    Servicio = 188714,
    TipoDoc = "D",
    NroDoc = 43400262
});

IRestResponse response = client.Execute(request);
var content = response.Content;
TextBox1.Text = response.Content;

A hug brother, you're on the right track:)

    
answered by 10.08.2018 / 19:37
source