Is it possible to send Request-headers to SharePoint Rest API which will be then present with the same value in the response?

Here is an example what I want to do:

getUserId: function (loginName, callback) {

    /// according to the environment.
    var executor = new SP.RequestExecutor(decodeURIComponent(AppCoreFunctions.getAppRelativeUrls().appweburl));
    var url = AppCoreFunctions.getAppRelativeUrls().appweburl + "/_api/SP.AppContextSite(@target)/web/siteusers(@v)?@v='" + SP.Utilities.HttpUtility.urlKeyValueEncode(loginName) + "'&@target='" + AppCoreFunctions.getAppRelativeUrls().hostweburl + "'";
        url: url,
        method: "GET",
        headers: {
            "accept": "application/json; odata=verbose",
            "__xyz": "123" //<-- I want to be able to read this data from response
        success: function (data, loginName) {
            var JSONData = JSON.parse(data["body"]);
        error: function (sender, args) {

No, that is impossible, unless you can change how the receiving server responds, so in SharePoints case only Microsoft can make that change

Use either

  • Scope binding
  • Cookies
  • Local Storage
| improve this answer | |

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.