cURLing SharePoint for a pdf file from a docker container not working completely

I have a docker desktop on windows 11.

When I cURL sharepoint from my laptop (host) for a pdf file, everything works perfectly, the pdf file is downloaded correctly on my laptop:
curl --location --request GET "'/sites/xxx/Shared%20Documents/xxx')/Files('file.pdf')/$value" --header "Authorization: Bearer xxx" --header "Accept: application/json;odata=verbose" --header "Content-Type: application/json" --output file.pdf

When I run the same cURL inside my docker container (Debian), Sharepoint responds but the pdf file received in the container is corrupted and is only 3.6KB instead of 3.9KB (for example).

Thanks for help.

Did you llook into the file to see the content? If it is an html or anything you can recignize that can help you to find a solution. You could try hexdump if you can install it in the container or copy the file out and use hexdump from WSL or use a hexdump alternative on Windows.

On linux:

hexdump -C --length 1000 file.pdf

That will show you 1000 bytes. hex codes on the left side and ascii characters on the left.

1 Like

Thank you @rimelek for your help.

Problem solved escaping $ in the URL with a backslash.

curl --location "'/sites/xxx/Shared%20Documents/xxx')/Files('file.pdf')/\$value" --header "Authorization: Bearer xxx" --output file.pdf

Of note, headers are not mandatory except for Authorization.

Please take a look at cURLing Sharepoint for a pdf file from docker container not working completely - Stack Overflow