Forum Discussion

Joe Wu's avatar
Joe Wu
Copper Contributor
Sep 20, 2023

A problem when download OneNote file using OneDrive api by curl

Hi Everyone,

When I try to download onenote files by OneDrive api, curl returns 56 when sending download requests for some onenote files.
Below is one of the details of the api request/reponse. I have tried to request the metadata of that onenote file and the api behaved as expected, so it seems that the issue is only related to the download itself.

Is it OneDrive api limitation such that some onenote files could not be downloaded ?

If I want to backup whole onenote file From M365 OneNote/Sharepoint, is oneNote api suitable to download all components of onenote file ? And is it suitable to restore the backup file to M365 OneDrive/SharePoint ?

 

curl -v   --location --request GET '[https://xxxx-my.sharepoint.com/_api/v2.0/drives/](https://xxxx-my.sharepoint.com/_api/v2.0/drives/)<my_drive_id>/items/<my_item_id>/content' --header 'Authorization: Bearer <Bearer>'

* TLSv1.2 (IN), TLS header, Supplemental data (23):

* TLSv1.2 (OUT), TLS header, Supplemental data (23):

* TLSv1.2 (IN), TLS header, Supplemental data (23):

* TLSv1.2 (IN), TLS header, Supplemental data (23):

< HTTP/2 302

< cache-control: no-cache, no-store

< pragma: no-cache

< content-type: application/octet-stream

< expires: -1

< location: [https://xxxx.sharepoint.com/sites/OS0709-D/_layouts/15/download.aspx?UniqueId=<uid>&Translate=false&...](https://xxxx.sharepoint.com/sites/OS0709-D/_layouts/15/download.aspx?UniqueId=0c5547be-c983-4782-a5d0-30df30f00072&Translate=false&tempauth=)<tempauth>&ApiVersion=2.0

< p3p: CP="ALL IND DSP COR ADM CONo CUR CUSo IVAo IVDo PSA PSD TAI TELo OUR SAMo CNT COM INT NAV ONL PHY PRE PUR UNI"

< x-networkstatistics: 0,525568,0,0,2094697,0,379488

< x-sharepointhealthscore: 3

< x-sp-serverstate: ReadOnly=0

< odata-version: 4.0

< x-download-options: noopen

< content-disposition: attachment

< spclientservicerequestduration: 36

< sprequestduration: 37

< x-aspnet-version: 4.0.30319

< x-databoundary: EU

< x-1dscollectorurl: [https://eu-mobile.events.data.microsoft.com/OneCollector/1.0/](https://eu-mobile.events.data.microsoft.com/OneCollector/1.0/)

< x-ariacollectorurl: [https://eu-mobile.events.data.microsoft.com/Collector/3.0](https://eu-mobile.events.data.microsoft.com/Collector/3.0)

< sprequestguid: ea24d6a0-107c-7000-3c47-9471817ea836

< request-id: ea24d6a0-107c-7000-3c47-9471817ea836

< ms-cv: oNYk6nwQAHA8R5RxgX6oNg.0

< strict-transport-security: max-age=31536000

< x-frame-options: SAMEORIGIN

< content-security-policy: frame-ancestors 'self' teams.microsoft.com *.teams.microsoft.com *.skype.com *.teams.microsoft.us local.teams.office.com teams.microsoftonline.cn *.powerapps.com *.yammer.com *.officeapps.live.com *.office.com *.stream.azure-test.net *.microsoftstream.com *.dynamics.com *.microsoft.com onedrive.live.com *.onedrive.live.com securebroker.sharepointonline.com;

< x-powered-by: ASP.NET

< microsoftsharepointteamservices: 16.0.0.24016

< x-content-type-options: nosniff

< x-ms-invokeapp: 1; RequireReadOnly

< x-cache: CONFIG_NOCACHE

< x-msedge-ref: Ref A: FC459A849CD54010845E23ECF71439CD Ref B: TPE30EDGE0912 Ref C: 2023-09-01T09:45:07Z

< date: Fri, 01 Sep 2023 09:45:07 GMT

< content-length: 0

< 

* TLSv1.0 (OUT), TLS header, Certificate Status (22):

* TLSv1.3 (OUT), TLS handshake, Client hello (1):

* TLSv1.2 (IN), TLS header, Certificate Status (22):

* TLSv1.3 (IN), TLS handshake, Server hello (2):

* TLSv1.2 (IN), TLS handshake, Certificate (11):

* TLSv1.2 (IN), TLS handshake, Server key exchange (12):

* TLSv1.2 (IN), TLS handshake, Server finished (14):

* TLSv1.2 (OUT), TLS header, Certificate Status (22):

* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):

* TLSv1.2 (OUT), TLS header, Finished (20):

* TLSv1.2 (OUT), TLS change cipher, Change cipher spec (1):

* TLSv1.2 (OUT), TLS header, Certificate Status (22):

* TLSv1.2 (OUT), TLS handshake, Finished (20):

* TLSv1.2 (IN), TLS header, Finished (20):

* TLSv1.2 (IN), TLS header, Certificate Status (22):

* TLSv1.2 (IN), TLS handshake, Finished (20):

* TLSv1.2 (OUT), TLS header, Supplemental data (23):

* TLSv1.2 (OUT), TLS header, Supplemental data (23):

* TLSv1.2 (OUT), TLS header, Supplemental data (23):

* TLSv1.2 (OUT), TLS header, Supplemental data (23):

> GET /sites/OS0709-D/_layouts/15/download.aspx?UniqueId=<uid>&Translate=false&tempauth=<tempauth>&ApiVersion=2.0 HTTP/2

> Host: xxxx.sharepoint.com

> user-agent: curl/7.86.0

> accept: */*

> 

* TLSv1.2 (IN), TLS header, Supplemental data (23):

* TLSv1.2 (OUT), TLS header, Supplemental data (23):

* TLSv1.2 (IN), TLS header, Supplemental data (23):

* TLSv1.2 (IN), TLS header, Supplemental data (23):

< HTTP/2 302

< cache-control: private

< content-type: text/plain

< location: [https://190124-ipv4v6.gr.global.aa-rt.sharepoint.com/sites/OS0709-D/_layouts/15/download.aspx?Unique...](https://190124-ipv4v6.gr.global.aa-rt.sharepoint.com/sites/OS0709-D/_layouts/15/download.aspx?UniqueId=0c5547be-c983-4782-a5d0-30df30f00072&Translate=false&siteHost=xxxx.sharepoint.com&tempauth=)<tempauth>&ApiVersion=2.0

< p3p: CP="ALL IND DSP COR ADM CONo CUR CUSo IVAo IVDo PSA PSD TAI TELo OUR SAMo CNT COM INT NAV ONL PHY PRE PUR UNI"

< x-networkstatistics: 0,525568,0,0,687952,0,97344

< x-sharepointhealthscore: 2

< sprequestguid: ea24d6a0-409a-7000-3c47-93101f35ea5e

< request-id: ea24d6a0-409a-7000-3c47-93101f35ea5e

< ms-cv: oNYk6ppAAHA8R5MQHzXqXg.0

< strict-transport-security: max-age=31536000

< x-aspnet-version: 4.0.30319

< sprequestduration: 25

< spiislatency: 1

< x-powered-by: ASP.NET

< microsoftsharepointteamservices: 16.0.0.24016

< x-content-type-options: nosniff

< x-ms-invokeapp: 1; RequireReadOnly

< x-cache: CONFIG_NOCACHE

< x-msedge-ref: Ref A: 0A695B98792B463DA2C4B0329A0DCE1E Ref B: TPE30EDGE0609 Ref C: 2023-09-01T09:45:08Z

< date: Fri, 01 Sep 2023 09:45:07 GMT

< content-length: 0

< 

* TLSv1.0 (OUT), TLS header, Certificate Status (22):

* TLSv1.3 (OUT), TLS handshake, Client hello (1):

* TLSv1.2 (IN), TLS header, Certificate Status (22):

* TLSv1.3 (IN), TLS handshake, Server hello (2):

* TLSv1.2 (IN), TLS handshake, Certificate (11):

* TLSv1.2 (IN), TLS handshake, Server key exchange (12):

* TLSv1.2 (IN), TLS handshake, Server finished (14):

* TLSv1.2 (OUT), TLS header, Certificate Status (22):

* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):

* TLSv1.2 (OUT), TLS header, Finished (20):

* TLSv1.2 (OUT), TLS change cipher, Change cipher spec (1):

* TLSv1.2 (OUT), TLS header, Certificate Status (22):

* TLSv1.2 (OUT), TLS handshake, Finished (20):

* TLSv1.2 (IN), TLS header, Finished (20):

* TLSv1.2 (IN), TLS header, Certificate Status (22):

* TLSv1.2 (IN), TLS handshake, Finished (20):

* TLSv1.2 (OUT), TLS header, Supplemental data (23):

> GET /sites/OS0709-D/_layouts/15/download.aspx?UniqueId=<uid>&Translate=false&siteHost=xxxx.sharepoint.com&tempauth=<tempauth>&ApiVersion=2.0 HTTP/1.1

> Host: 190124-ipv4v6.gr.global.aa-rt.sharepoint.com

> User-Agent: curl/7.86.0

> Accept: */*

> 

* TLSv1.2 (OUT), TLS header, Unknown (21):

* TLSv1.2 (OUT), TLS alert, decode error (562):

* OpenSSL SSL_read: error:0A000126:SSL routines::unexpected eof while reading, errno 0

curl: (56) OpenSSL SSL_read: error:0A000126:SSL routines::unexpected eof while reading, errno 0

 


```

5 Replies

  • Joe Wu 

    The error code 56 in curl indicates a failure in receiving network data. This error may be caused by a lack of TLS 1.2 support on your Linux clients. TLS 1.2 is a security protocol that OneDrive requires for authentication.

    To fix this issue, you may need to update your Linux clients to support TLS 1.2 or higher, or disable DHE cipher suites.

     

    Regarding your second question, the OneNote API is suitable for downloading all components of an OneNote file and restoring the backup file to M365 OneDrive/SharePoint. 

     

    If I have answered your question, please mark your post as Solved

    If you like my response, please give it a Like :smile:

    Appreciate your Kudos! Proud to contribute! ðŸ™‚

     

    • Joe Wu's avatar
      Joe Wu
      Copper Contributor
      Deleted
      Thanks for the reply.

      In our case, the curl error of download only occurs on a few onenote files. Other onenote files still can be downloaded. Also for the onenote files that are failed to download by OneDrive graph api, can still get the metadata of files by OneDrive graph api.
      If there is a lack of TLS 1.2 support on Linux clients, then all onenote files should be unable to download, I suppose?

      Also thanks for your answer about the second question. We would consider to use OneNote api.
      • Deleted's avatar
        Deleted

        Joe Wu 

        In your case, you mentioned that the curl error of download only occurs on a few OneNote files, while other OneNote files can still be downloaded. Additionally, you mentioned that for the OneNote files that failed to download by OneDrive Graph API, you can still get the metadata of the file by OneDrive Graph API.

         

        Regarding your question about whether there is a lack of TLS 1.2 support on Linux clients, it is not necessarily true that all OneNote files should be unable to download if there is a lack of TLS 1.2 support on Linux clients. The reason is that the TLS version used for communication between the client and server depends on the server’s configuration and the client’s capabilities. If the server supports TLS 1.2 and the client does not, then the communication will fail. However, if the server supports an earlier version of TLS that the client supports, then communication will still be possible.

         

        If you are experiencing issues with downloading OneNote files using OneDrive Graph API, it might be helpful to check if your Linux client supports TLS 1.2 and if it is enabled. You can use OpenSSL to check if your Linux client supports TLS 1.2 by running openssl s_client -connect <server>:<port> -tls1_2. If your client does not support TLS 1.2, you can try enabling it by following the instructions provided by your Linux distribution or OpenSSL documentation.

         

         

         

         

        If I have answered your question, please mark your post as Solved

        If you like my response, please give it a Like :smile:

        Appreciate your Kudos! Proud to contribute! ðŸ™‚

         

Resources