SharePoint Web API - URL Doesn't work with hyphen ("-") in url

1.5k Views Asked by At

I have a SharePoint url which works perfectly fine this points to the production environment I am using nodejs with getFileByName method to consume this url -

https://xxxx.sharepoint.com/sites/MSDS/Construction/_api/web/GetFileByServerRelativeUrl('/sites/MSDS/Construction/ProductLabels/xxxx.pdf')/$value

Now below is the quality server url which doesn't work at all -

https://xxxx.sharepoint.com/sites/qa-MSDS/Construction/_api/web/GetFileByServerRelativeUrl('/sites/qa-MSDS/Construction/ProductLabels/xxxx.pdf')/$value

The difference is qa-MSDS instead of MSDS, when I use the qa web api I get below error -

<m:error xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<m:code>-2147024809, System.ArgumentException</m:code>
<m:message xml:lang="en-US">
Server relative urls must start with SPWeb.ServerRelativeUrl
</m:message>
</m:error>

Can anyone suggest what I am doing wrong or how to solve this in a better way in node js environment?

0

There are 0 best solutions below