[progress Communities] [progress Openedge Abl] Forum Post: Posting Binary Body (file...

  • Thread starter Thread starter Niall Morgan
  • Start date Start date
Status
Not open for further replies.
N

Niall Morgan

Guest
I'm trying to use the SharePoint Office 365 API to send files to SharePoint. I have managed to get the file to arrive in share point but it is corrupted when it gets there.I believe this is because the data needs to be sent in binary format and progress is sending it in some other format. Could someone point me in the right direction on how to properly encode the post body as binary data ? This is what i'm doing, but its not working properly. Files arrive, but they have no data. DEFINE VARIABLE encdmptr AS MEMPTR NO-UNDO. DEFINE VARIABLE result AS CHARACTER NO-UNDO. DEFINE VARIABLE encdlngc AS LONGCHAR NO-UNDO. def var cWebServiceUrl as char no-undo. def var oBody AS OpenEdge.Core.ByteBucket NO-UNDO. /* im not sure this is correct */ COPY-LOB FROM FILE "C:\Users\me\Desktop\testupload.xlsx" TO encdmptr NO-CONVERT NO-ERROR. encdlngc = BASE64-ENCODE(encdmptr). cDocLib = "DOCLIB IN SHAREPOINT". cWebServiceUrl = " yoursharepointsite.com/.../GetFolderByServerRelativeUrl('DOCLIB IN SHAREPOINT')/Files/add(url='testupload.xlsx',overwrite=true)". /* post body params */ /* again this is probably not correct */ oBody = NEW OpenEdge.Core.ByteBucket(encdlngc). /* send post request for token */ oRequest = RequestBuilder:Post(cWebServiceUrl, oBody) :AddHeader("Accept","application/json;odata=verbose") :AddHeader("Authorization", "Bearer " + cAccessToken) :Request. oResponse = ClientBuilder:Build():Client:Execute(oRequest). IF oResponse:StatusCode <> 200 THEN DO: MESSAGE oResponse:StatusCode SKIP oResponse:StatusReason SKIP VIEW-AS ALERT-BOX. END. /* parse response */ oJsonEntity = CAST(oResponse:Entity, JsonObject). /* just for debugging */ Message oJsonEntity:GetJsonObject('d'):GetJsonObject('__metadata'):GetCharacter('id'). RETURN result.

Continue reading...
 
Status
Not open for further replies.
Back
Top