Quantcast
Channel: Developing Apps for SharePoint 2013 forum
Viewing all articles
Browse latest Browse all 8089

App using REST API : error "No Transport"

$
0
0

Hi Team,

i am developing a simple app to create an item in a list using Jquery and the REST API. when i run the app i get teh error "No Transport"

creating a sharepoint hosted app- so whne i deploy and install the app and click the button on the default.aspx page i get the error.

on default.aspx page i have a button

code below

buttonid="getitems"onclick="restapi()"type="submit"> Get Items</button>

app.js code below

 function restapi() {

        var list = "testli";   // Create
        createItem(list, JSON.stringify({ '__metadata': { 'type': 'SP.Data.' + list + 'ListItem' }, 'Name': 'John', 'Surname': 'Doe', 'School': 'Microsoft Academic', 'Title': 'John' }),
            function () { alert("Student created"); });   // Read all
       
    }

   
    function createItem (list, data, callback) {
        $.ajax({
            url: "http://server/sites/aaa/_api/web/lists/getByTitle('" + list + "')/items",
           // url:  feedManagerEndpoint+"web/lists/getByTitle('" + list + "')/items",
            type: "POST",
                      
            contentType: "application/json;odata=verbose",
            data: data,
            headers: {
                "accept": "application/json;odata=verbose",
                "X-RequestDigest": $("#__REQUESTDIGEST").val()
            },
            success: function () {
                if (callback !== undefined) callback();
            },
            error: function (err) {
                $('#message1').text("ERROR123 : " + JSON.stringify(err));
            }
        });
    }


Viewing all articles
Browse latest Browse all 8089


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>