Any Answers Will Help me to Forward and Gain Knowledge in SharePoint Development

While i am Trying to get the list Items Using Rest API Calls in SharePoint Hosted App Using Below Function

function loadingSamples() 
    var JobListName = "RRR Jobs #";
    var executor;
    // Initialize the RequestExecutor with the app web URL.
    executor = new SP.RequestExecutor("/");

    //Fetching the choice values from the Job Status Field, to show in the Dropdown field
        url: "/_api/web/lists/getbytitle('" + encodeURIComponent(JobListName) + "')/fields/getbytitle('Job Status')?$select=Choices",
        method: "GET",
        headers: { "Accept": "application/json; odata=verbose" },
        success: successHandlerStatus,
        error: errorHandler
function successHandlerStatus(data) 

function errorHandler(data, errorCode, errorMessage) 

It's always going to error function named errorHandler With Error Code as -1002 and Error Message as Bad Request and Inside Data -> Body , the Error message is

            "value":"The expression \"web/lists/getbytitle('DWR Jobs \" is not valid."

Note :

  • This is working code in Sharepoint Hosted App that previously hosted in another Windows server.

  • Now i hosted this App in New windows server,it's successfully hosted but it gives above mentioned Error in Rest Service Call.


SharePoint does not trust your blue-eyed REST call without you passing an extra proof your call came from that SharePoint Page

Wictor explains it all at http://www.wictorwilen.se/sharepoint-2013-how-to-refresh-the-request-digest-value-in-javascript

Oh, one thing.. Wictors example requires jQuery to get a DOM value; which you can do completely without loadin an extra 90K jQuery library:

| improve this answer | |
  • document.getElementById('__REQUESTDIGEST').value is used While Posting and updating. But i am using Get Functionality. And Also its working in another windows server. why its giving error in new server. – Vignesh amutha May 9 '16 at 9:36
  • You are right, but.. there must be an authentication handshake because you are making a call to the HostWeb .. which is a different server – Danny '365CSI' Engelman May 9 '16 at 10:34
  • In Another Server Same Code is Working Perfectly. But it's not working in my Server and gives the error in the above mentioned code. What Kind of Authentication it Needs.? – Vignesh amutha May 9 '16 at 10:43
  • I dont know, If this runs for you on another of your servers, it is a clear indication it is your authentication problem and not a SharePoint coding error. – Danny '365CSI' Engelman May 9 '16 at 12:31
  • Thanks Danny, you gave me a great idea i will concentrate on the authentication problem instead of Code. – Vignesh amutha May 9 '16 at 13:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.