samedi 7 novembre 2015

how to add fiddler request body parameters in ajax call

Please check my ajax code and image of fiddler. If I use fiddler , I am getting output.But in ajax call,giving error like bad req.

   $.ajax({
                type: "POST",
                url: "http://localhost:54544/token",
                contentType: "application/form-url-encoded",
                data: JSON.stringify({
                    grant_type: "password",
                    Username: "user",
                    Password: "user"
                }),
                
                success: function (data) {
                    alert("succ");
                    alert(data);
                },
                error: function (xhr, status, p3, p4) {

                    var err = "Error " + " " + status + " " + p3;
                    if (xhr.responseText && xhr.responseText[0] == "{")
                        err = JSON.parse(xhr.responseText).message;
                    alert(err);
                }
            });

fiddler req img output in fiddler img

Aucun commentaire:

Enregistrer un commentaire