sharepoint 2013 REST api call APP web list into host web

Hi ,

I have situation like below :

1) Host site  "http://test-dev06/sites/AppCatalogSite"

2)App web "http://fkapp-5584745e26d248.test-dev06/sites/AppCatalogSite/PNCFASTKnowledgeManagementApp

this site has list name "Projects"

My requirement :

I have created page into  host site's  sitepages / "AddPage.aspx"

i want to  read/write item into "ProjectList"  in app web 

i have below code that i have used into HostSite page but getting error :

status code =0 

ready state =0

error code= "error"

<a href="#" onclick="ReturnListData()">add item</a><br/>

<script type="text/javascript" src="https://code.jquery.com/jquery-2.1.2.min.js" ></script>

  <script type="text/jscript">



  function ReturnListData() {    
    $.ajax({
        type: "GET",
        url: "http://fkapp-5584745e26d248.test-dev06/sites/AppCatalogSite/PNCFASTKnowledgeManagementApp/_api/lists/getbytitle('Projects')/Items",
        contentType: "application/json; charset=utf-8",
        headers: { "Accept": "application/json; odata=verbose" },
        success: successHandler,
        error: errorHandler
    }).done(function () {
        //console.log("RequestEnded");

    });
}

function errorHandler(data, errorCode, errorMessage) {      
    console.log("errorHandler");
    document.getElementById("lblResult").innerText =
        "Could not complete: " + errorMessage;

}

function successHandler(data) {
    console.log("successHandler");
    var jsonObject = data.d.results;        
}
</script>

August 26th, 2015 7:31pm

Hi,

Please modify the code as below:

<a href="#" onclick="ReturnListData()">add item</a><br/>
<script type="text/javascript" src="https://code.jquery.com/jquery-2.1.2.min.js" ></script>
<script type="text/jscript">
function ReturnListData() {    
 $.ajax({
	 type: "GET",
	 url: "http://test-dev06/sites/AppCatalogSite/PNCFASTKnowledgeManagementApp/_api/lists/getbytitle('Projects')/Items",
	 contentType: "application/json; charset=utf-8",
	 headers: { "Accept": "application/json; odata=verbose" },
	 success: successHandler,
	 error: errorHandler
 }).done(function () {
	 //console.log("RequestEnded");
 });
}

function errorHandler(data, errorCode, errorMessage) {      
 console.log("errorHandler");
 document.getElementById("lblResult").innerText =
	 "Could not complete: " + errorMessage;

}

function successHandler(data) {
 console.log("successHandler");
 var jsonObject = data.d.results;        
}
</script> 

Best Regards,

Dennis

Free Windows Admin Tool Kit Click here and download it now
August 28th, 2015 9:22am

Hi Dennis,

Thanks  for correcting the code 

this line helped me :

 url: "http://test-dev06/sites/AppCatalogSite/PNCFASTKnowledgeManagementApp/_api/lists/getbytitle('Projects')/Items",
	

August 29th, 2015 6:35am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics