[ardoHTTP] Please add support for Binary

Forge Component
Published on 2019-01-20 by Ricardo Silva
20 votes
Published on 2019-01-20 by Ricardo Silva


I currently creating an component to work with the Microsoft Graph API for SharePoint. One of the features is uploading a file via an UploadSession. The problem with this is, is that instead that the upload is handled via Microsoft Graph (https://microsoft.graph.com/...) the uploadsession is handled directly with the SharePoint tenant in question, example: "https://<tenant>.sharepoint.com/sites/...". This prevents me from using the default REST in OutSystems because I can't define a complete URL, I already need to know the root (and yes, you can change that in ServiceCenter but if you have multiple tenants like us that possibility is not the solution). 

I could to create my own version of this request but this is very useful and I think it should be in the base pacakge. I opened the package and I think that it's real easy to add this since it requires only changes in the called function. I added the resulting function below for the PUT operation. 

public void MssHTTPPutBinary(string ssURL, RLHTTPHeaderRecordList ssHeaders, byte[] ssData, string ssContent_Type, string ssUsername, string ssPassword, out string ssStatus, out int ssStatus_Code, out string ssResponse, out RLHTTPHeaderBinaryRecordList ssResponse_Headers)
            ssStatus = "";
            ssStatus_Code = 0;
            ssResponse = "";
            ssResponse_Headers = new RLHTTPHeaderRecordList();

            if (ssContent_Type != "")
                RCHTTPHeaderRecord ct_header = new RCHTTPHeaderRecord(null);
                ct_header.ssSTHTTPHeader.ssName = "Content-Type";
                ct_header.ssSTHTTPHeader.ssValue = ssContent_Type;

            processResponse(processRequest("PUT", ssURL, ssHeaders, new NetworkCredential(ssUsername, ssPassword), ssData), out ssStatus, out ssStatus_Code, out ssResponse, ssResponse_Headers);
        } // MssHTTPPutBinary

Kind regards,

Vincent Koning

Hello Vincent, 

Couldn't you use the On Before Request callback  and change the address? 

Something like this, maybe? https://www.outsystems.com/forums/discussion/22341/change-rest-server-at-runtime/


Hi Eduardo,

I didn't know about this possibility. I will surely attempt to do this but there another caveat that could throw some issues, on receiving the last chunck of the binary blob the Graph API returns a different JSON and it does when it expects new chuncks.