'Upload file to onedrive personel via VBA REST API

There is simple code for upload file to dropbox. Does someone have an example of a similar code for Onedrive

Function uploadSave(stm As ADODB.Stream, fname As String, token As String) As integer
    Const lngTimeout = 890000
    Dim http As WinHttp.WinHttpRequest
    Set http = CreateObject("WinHttp.WinHttpRequest.5.1")
    http.SetTimeouts lngTimeout, lngTimeout, lngTimeout, lngTimeout
    http.Open "POST", "https://content.dropboxapi.com/2/files/upload", False
    http.setRequestHeader "Content-Length", stm.Size
    http.setRequestHeader "Authorization", "Bearer " & token
    http.setRequestHeader "User-Agent", "api-explorer-client"
    http.setRequestHeader "Content-Type", "application/octet-stream"
    http.setRequestHeader "Dropbox-API-Arg", "{""path"":""" & fname & """,""mode"":{"".tag"":""overwrite""},""autorename"":true}"
    http.Send (stm.Read)
    Set stm = Nothing
            uploadSave = http.Status 
End Function


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source