locked
how to call web Api in asp.net project RRS feed

  • Question

  • User377613556 posted

    Hi,

    I am new to web api.

     I have one asp.net project and one web api project. Just i want to consume the web api in asp.net proejct. both projects are in same solution only.

    below is my code to call web api.

    <script type="text/javascript">
    $(document).ready(function () {

    PDFTemplateViewModel = {
    PDFTemplateID: 1
    }

    $('#btnLogin').click(function () {
    debugger;
    $.ajax({
    url: 'api/TestingService/GetPDFTemplateDetailsById',
    type: 'POST',
    contentType: 'application/json; charset=utf-8',
    data: JSON.stringify(PDFTemplateViewModel),
    dataType: 'json',
    success: function (data) {
    alert(data);
    },
    error: function (request, status, error) {
    alert(request.responseText);
    }
    });
    });

    });

    </script>

    Thanks,

    Ra

    Wednesday, May 10, 2017 10:51 AM

All replies

  • User632428103 posted

    Hello ramakrishnan27,

    i think your url isn't correct your path should be http://yourAPIProject/ ...

    hope this help

    Wednesday, May 10, 2017 12:39 PM
  • User-2057865890 posted

    Hi Ra,

    Can you describe exactly what you are facing? It is better if you could share the api code you are using.

    Best Regards,

    Chris

    Thursday, May 11, 2017 8:43 AM