I am trying to get stream of an attachment, I am using Copy.asmx I can get a stream of a document stored in a document library but for the attachment I get 0 result.

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<GetItemResponse xmlns="http://schemas.microsoft.com/sharepoint/soap/">

1 Answer 1


You could try this, SPServices is wraped with soap service.

<script type="text/javascript" src="https://code.jquery.com/jquery-1.11.2.min.js"></script>
    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery.SPServices/2014.02/jquery.SPServices.js"></script>
    <script type="text/javascript">
        $(function () {
                operation: "GetAttachmentCollection",
                async: false,
                listName: "Test",
                ID: 1,
                completefunc: function (xData, Status) {
                    //suppose only one attachement file
                    $(xData.responseXML).find("Attachment").each(function () {
                        var url = $(this).text();

                        var request = new XMLHttpRequest();
                        request.open('GET', url, true);
                        request.responseType = 'blob';
                        request.onload = function () {
                            var reader = new FileReader();
                            reader.onload = function (e) {
                                //binary stream
                                console.log('DataURL:', e.target.result);



Test result.

enter image description here

  • does this return binary stream in base 64 format?
    – Ali
    Commented Jun 30, 2020 at 7:28
  • Check the update.
    – Lee
    Commented Jun 30, 2020 at 8:00

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.