Im currently trying to build a SharePoint Add-in that tells you who's birthday it is on the current date. I would like to use the SharePoint search api for this but im struggling with an issue. Currently im using this simple code:

          var spHostUrl = GetUrlKeyValue('SPHostUrl');


                   url: spHostUrl + "/_api/search/query?querytext=%27Date01:2000-05-31%27&sourceid=%27B09A7990-05EA-4AF9-81EF-EDFAB16C4E31%27",

                   method: "GET",
                   headers: {
                       "accept": "application/json; odata=verbose",
                   success: function (data) {


                   error: function (data) {


this should give me a JSON object containing the people with their birthday on 31 May. When i add the _api url to my site url (hostweburl) in the browser it returns XML containing 1 row with the correct user having its birthday on the 31st May. When i add the _api url to the Appweburl in the browser i receive XML containing 0 rows. So thats why im using "GetUrlKeyValue('SPHostUrl')".

For some reason when i run this code the debugger tells me the ajax call got an error(not going in success) and the JSON object contains an error. BUT when i use fidler i can clearly see the ajax call got a '200' status and contains a json object with the correct row.

So now im seriously confused, im thinking this has something to do with permissions ?? it looks like im not able to call the api on the hostweb from within the add-in or appweb.

extra info : the sourceid is the people result source and "Date01" is a managed property i mapped to the SPS-Birthday property.

1 Answer 1


I found the answer myself, when i removed the hosturl before the api url it worked.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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