Hi,
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; ssHeaders.Append(ct_header); } 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/
Cheers
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.
Just to get back to this issue. I'm about to add a forge component that depended on a custom version of this component that allows binary PUT actions. I was unable to get a working version of this requirement with the build-in REST capability of OutSystems. So before I go ahead and post an addendum of this component to the forge I would like to ask you again to add this capability to ardoHTTP. I think more people would benefit from this and it will keep everything in one component which is important to me.
The action that I have created is as follows;
As you can see it's a copy of the original HTTPPut action with the Data changed to Binary Data.
Greetings,
Vincent
Hi Vincent,
Did you happen to publish this Forge component with the HTTPPutBinary?
As mentioned in my other post in this thread, I also need the HTTPPut, HTTPPatch and HTTPPost actions to accept Binary Data instead of Text data. And I was also thinking of adding my own ardoHTTP version with these changes.
Steven
I had the same requirement to POST/PUT/PATCH binary data. I adapted the HTTPPut, HTTPPatch and HTTPPost to include a BinaryData input parameter next to the Data input parameter.
If the Data input parameter is empty (""), the BinaryData input parameter is used instead.
It would be great if these changes could be added to the ardoHTTP component, as this seems to be the most popular one. I'm happy to make the changes myself if I'm added to the team.
If these changes are not added to ardoHTTP I'm also, like Vincent, thinking of publishing my own clone of ardoHTTP with these changes as I think they are needed by the community. But like him I prefer to have the changes included in ardoHTTP if possible.
Below you can find the diff file with the code changes (I highlighted the changes in bold):
-------------------------------------------
68c68
< public void MssHTTPPatch(string ssURL, RLHTTPHeaderRecordList ssHeaders, string ssData, string ssContent_Type, string ssUsername, string ssPassword, out string ssStatus, out int ssStatus_Code, out string ssResponse, out RLHTTPHeaderRecordList ssResponse_Headers) {
---
> public void MssHTTPPatch(string ssURL, RLHTTPHeaderRecordList ssHeaders, string ssData, byte[] ssBinaryData, string ssContent_Type, string ssUsername, string ssPassword, out string ssStatus, out int ssStatus_Code, out string ssResponse, out RLHTTPHeaderRecordList ssResponse_Headers) {
80c80
< processResponse(processRequest("PATCH", ssURL, ssHeaders, new NetworkCredential(ssUsername, ssPassword), Encoding.UTF8.GetBytes(ssData)), out ssStatus, out ssStatus_Code, out ssResponse, ssResponse_Headers);
> processResponse(processRequest("PATCH", ssURL, ssHeaders, new NetworkCredential(ssUsername, ssPassword), ssData != "" ? Encoding.UTF8.GetBytes(ssData) : ssBinaryData), out ssStatus, out ssStatus_Code, out ssResponse, ssResponse_Headers);
109c109
< public void MssHTTPPut(string ssURL, RLHTTPHeaderRecordList ssHeaders, string ssData, string ssContent_Type, string ssUsername, string ssPassword, out string ssStatus, out int ssStatus_Code, out string ssResponse, out RLHTTPHeaderRecordList ssResponse_Headers)
> public void MssHTTPPut(string ssURL, RLHTTPHeaderRecordList ssHeaders, string ssData, byte[] ssBinaryData, string ssContent_Type, string ssUsername, string ssPassword, out string ssStatus, out int ssStatus_Code, out string ssResponse, out RLHTTPHeaderRecordList ssResponse_Headers)
122c122
< processResponse(processRequest("PUT", ssURL, ssHeaders, new NetworkCredential(ssUsername, ssPassword), Encoding.UTF8.GetBytes(ssData)), out ssStatus, out ssStatus_Code, out ssResponse, ssResponse_Headers);
> processResponse(processRequest("PUT", ssURL, ssHeaders, new NetworkCredential(ssUsername, ssPassword), ssData != "" ? Encoding.UTF8.GetBytes(ssData) : ssBinaryData), out ssStatus, out ssStatus_Code, out ssResponse, ssResponse_Headers);
354c354
< public void MssHTTPPost(string ssURL, RLHTTPHeaderRecordList ssHeaders, string ssData, string ssContent_Type, string ssUsername, string ssPassword, out string ssStatus, out int ssStatus_Code, out string ssResponse, out RLHTTPHeaderRecordList ssResponse_Headers)
> public void MssHTTPPost(string ssURL, RLHTTPHeaderRecordList ssHeaders, string ssData, byte[] ssBinaryData, string ssContent_Type, string ssUsername, string ssPassword, out string ssStatus, out int ssStatus_Code, out string ssResponse, out RLHTTPHeaderRecordList ssResponse_Headers)
366c366
< processResponse(processRequest("POST", ssURL, ssHeaders, new NetworkCredential(ssUsername, ssPassword), Encoding.UTF8.GetBytes(ssData)), out ssStatus, out ssStatus_Code, out ssResponse, ssResponse_Headers);
> processResponse(processRequest("POST", ssURL, ssHeaders, new NetworkCredential(ssUsername, ssPassword), ssData != "" ? Encoding.UTF8.GetBytes(ssData) : ssBinaryData), out ssStatus, out ssStatus_Code, out ssResponse, ssResponse_Headers);