1

In sharepoint 2013 rest api, I have a list of items, and some of the items, I created, so its created by field will be my account. How can I use rest to download all items, where the modified by field is my account? Is there a [Me] variable I can use something like:

&$filter=Author eq Me

In view settings there is things like [Me] or [Today] so is there something like this for REST?

Thanks

2 Answers 2

1

Tried this in my environment (SharePoint 2013 on-prem) and it is working for me.

<script type="text/javascript">

    $(document).ready(function() {    

        // Get current user id
        var userid = _spPageContextInfo.userId;
        console.log(userid);

        // Rest call Created by current user
        // var requestUri = "/_api/lists/getbytitle('Listname')/items?$select=Title,Author/Id&$filter=Author/Id eq " + userid + "&$expand=Author";

        // Rest call Modified by current user
        var requestUri = "/_api/lists/getbytitle('Listname')/items?$select=Title,Editor/Id&$filter=Editor/Id eq " + userid + "&$expand=Editor";     

            $.ajax({
                url: requestUri,
                type: "GET",
                headers: { "ACCEPT": "application/json;odata=verbose" },
                success: function (data) {
                    $.each(data.d.results, function (i, item){
                        var title = item.Title;

                        console.log("The title is: " + title);

                    })
                },
                error: function () {
                    alert("Error getting items");
                }                     
            });   

    });
</script>

Hope this helps.

0

Unfortunately no. From the documentation at https://msdn.microsoft.com/en-us/library/fp142385.aspx

Query for users

In the SharePoint REST service, users are represented by the user's friendly (display) name, and not their alias or domain\alias combination. Therefore, you must construct user queries against users' friendly names.

NOTE

Membership-based user queries are not supported. Usage of the Current operator to do queries using the ID of the current user is not supported.

Are you stuck with the REST service? There are probably better options if you have access to the JSOM or CSOM.

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.