When running the _spo file get_ like in the PnP Starter Bash script the following command results in an error:
o365 spo file get --webUrl https://tenant.sharepoint.com/sites/pnp_tst_portal --url /sites/pnp_tst_portal/SiteAssets/hero.jpg
Error: serverRelativeUrl Parameter name: Specified value is not supported for the serverRelativeUrl parameter.
When I use the following command I do get a result.
o365 spo file get --webUrl https://tenant.sharepoint.com/sites/pnp_tst_portal --id d043bad5-d483-5cdd-9f44-d0f79edc251e
When I first run the command:
office365
and then the following command I also get a result:
spo file get --webUrl https://tenant.sharepoint.com/sites/pnp_tst_portal --url /sites/pnp_tst_portal/SiteAssets/hero.jpg
Also, when I construct the _api call that is behind the _spo file get_ command I get a result:
https://tenant.sharepoint.com/sites/pnp_tst_portal/_api/web/GetFileByServerRelativeUrl('/sites/pnp_tst_portal/SiteAssets/hero.jpg')
@eugenedauphin, could you please let me know what is the behavior in interactive mode where you execute commands without the o365?
Can you also test adding single and double quote around file server relative url like:
sh
o365 spo file get --webUrl "https://tenant.sharepoint.com/sites/pnp_tst_portal" --url "/sites/pnp_tst_portal/SiteAssets/hero.jpg"
@eugenedauphin on which OS and in which shell are you calling the command?
I can't repro it in zsh on macOS. When I call the command like you mentioned, it's working as expected.
I am running Git Bash on Windows 10.
@eugenedauphin, could you please let me know what is the behavior in
interactive modewhere you execute commands without theo365?Can you also test adding single and double quote around file server relative url like:
o365 spo file get --webUrl "https://tenant.sharepoint.com/sites/pnp_tst_portal" --url "/sites/pnp_tst_portal/SiteAssets/hero.jpg"
When I run the command with single or double quotes I get the same error with o365 spo file get
With interactive mode you mean first executing $ office365? In that case I do get a result (as described above).
Still can't repro. I'm calling the following in bash on Windows 10:
o365 spo file get --webUrl https://contoso.sharepoint.com/sites/sales --url /sites/sales/siteassets/1548-commercial16_exec_04.jpg
If you add --debug to the command, what is the generated URL of the REST request?
If you add
--debugto the command, what is the generated URL of the REST request?
The generated request is the issue, calling this url results in an error (serverRelativeUrl
Parameter name: Specified value is not supported for the serverRelativeUrl parameter.):
https://tenant.sharepoint.com/sites/pnp_tst_portal/_api/web/GetFileByServerRelativeUrl('C%3A%2FProgram%20Files%2FGit%2Fsites%2Fpnp_tst_portal%2FSiteAssets%2Fhero.jpg')
I am installing the Windows bash and will retry.
It's odd that for some reason the CLI is resolving the local file path before issuing the request. Do you have any aliases defined or anything else that could explain this behavior?
It's odd that for some reason the CLI is resolving the local file path before issuing the request. Do you have any aliases defined or anything else that could explain this behavior?
I found out that it is related to Git Bash
https://github.com/git-for-windows/build-extra/blob/master/ReleaseNotes.md
_If you specify command-line options starting with a slash, POSIX-to-Windows path conversion will kick in converting e.g. "/usr/bin/bash.exe" to "C:\Program Files\Git\usr\bin\bash.exe"._
So this command will work in Git Bash:
o365 spo file get --webUrl https://tenant.sharepoint.com/sites/pnp_tst_portal --url //sites/pnp_tst_portal/SiteAssets/hero.jpg --output json --debug
That is a very good catch indeed. Thanks for your finding! That might help someone else that uses Git Bash.
Closing as unrelated to the CLI. Thanks for sharing the details @eugenedauphin. I'm sure it will be helpful to others! 馃憦
Most helpful comment
I found out that it is related to Git Bash
https://github.com/git-for-windows/build-extra/blob/master/ReleaseNotes.md
_If you specify command-line options starting with a slash, POSIX-to-Windows path conversion will kick in converting e.g. "/usr/bin/bash.exe" to "C:\Program Files\Git\usr\bin\bash.exe"._
So this command will work in Git Bash:
o365 spo file get --webUrl https://tenant.sharepoint.com/sites/pnp_tst_portal --url //sites/pnp_tst_portal/SiteAssets/hero.jpg --output json --debug