SharePoint REST API GetFileByServerRelativeUrl not working - api

I'm trying to fetch a file, which is downloable in the following URL https://notarealurl.com/sites/name/subname/My%20Folder/test.htm with the following method:
fetch("/_api/web/GetFileByServerRelativeUrl('/sites/name/subname/My%20Folder/test.htm')/$value");
However it returns 404. I've tried with and without decoding the URL. Also, using the following request, doesn't return any file, just an almost empty response. Request:
fetch("/_api/web/GetFolderByServerRelativeUrl('/sites/name/subname/My%20Folder')/files");
Response:
<?xml version="1.0" encoding="utf-8"?><feed xml:base="https://notarealurl.com/_api/" xmlns="http://www.w3.org/2005/Atom" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns:georss="http://www.georss.org/georss" xmlns:gml="http://www.opengis.net/gml"><id>ab8997b7-04a9-4e43-a63f-486e9477e31b</id><title /><updated>2020-04-08T12:00:40Z</updated><author><name /></author></feed>

The correct API URL begins from the parent directory, the correct one is:
fetch("/sites/name/subname/_api/web/GetFileByServerRelativeUrl('/sites/name/subname/My%20Folder/test.htm')/$value");

I tested the following endpoint and it works well.
_spPageContextInfo.webAbsoluteUrl/_api/web/GetFileByServerRelativeUrl('_spPageContextInfo.webServerRelativeUrl/DocuentLibraryName/DocumentName')/$value
And here is one similar threads for your reference:
How to download file from document Library using Rest Api
Best Regards,
Baker Kong

Related

Workday REST API Endpoint Help Needed

I'm able to get an access token from workday, but I'm having trouble with understanding the resource endpoints. I've not been able to get any of the following to work. The ID I'm using does exist in the tenant.
ONE - this workday article, https://community.workday.com/articles/665624, says REST API URLs must follow this path format:
(basepath)/api/(service)/(version)/(tenant)/(resource)
my request - https://(domain)/ccx/api/customerAccounts/v1/(tenant)/customers/(id) --> 404 not found
TWO - The swagger file for customers says the base URL is:
https://(tenant hostname)/customerAccounts/v1
my request - https://(domain)/ccx/customerAccounts/v1/customers/(id) --> 404 not found
THREE - The rest client configuration says the Rest endpoint is: https://(domain)/ccx/api/v1/(tenant)
my request - https://(domain)/ccx/api/v1/(tenant)/customerAccounts/v1/customers/(id) --> 404 not found
Does anyone know what the URL endpoints should look like? A specific example would be appreciated.
Thanks!
Format is as follows. My issue appears be security related.
Am still having issues here with standard objects.
https://(domain)/ccx/api/customerAccounts/v1/(tennant)/customers/(ID)
for custom objects. this is confirmed to work.
https://(domain)/ccx/api/v1/(tennant)/customObjects/(objectAlias)/(ID)

Microsoft graph api download file content doesn't return doesn't return download URL

I want to download the content of a file in order to store it in local machine, the request I sent is:
https://graph.microsoft.com/v1.0/me/drive/root:/test/file1.docx:/content
get.addHeader("Accept", "application/octet-stream"),
get.addHeader('Authorization', authcode);
get.addHeader('Cache-Control', 'no-store');
the response code is 200 not 302. When I use my personal account the response header is jason object which has Content-Location (it is a download url). So far so good.
But when I use business account, the response code is 200 but there is no downaloadurl/contentlocation/ or anything similar in the response header.
All the permissions I think is fine, the scope in Azure is set to "Files.ReadWrite.All".
PS: I don't want to download the file, I want to download the filecontent.
Any suggestions?
Update: looks like this is known issue, there is already a case for that https://github.com/microsoftgraph/microsoft-graph-docs/issues/5637
Could you please share more detailed steps and screenshots?
I tested the API, everything is fine:
Another way is also mentioned in the github issue page:
We can get the #microsoft.graph.downloadUrl feom the metedata:

TopDesk: Unable to get authorization token using Login API

Referring to TopDesk's Login API,
I'm using PostMan to be authorized.
GET http://www.topdesk.com/api/login/person
Authorization: Basic <base64 encoded password removed>
However, I get 404 Not Found Error and Content-Type is html.
I was expecting it to be either:
200 - OK
401 - Unauthorized
500-Internal-Server-Error
in JSON format.
Any ideas?
Looking at the docs I don't think http://www.topdesk.com/ is the base URL for the API. I don't know what your specific API URL is.
Do you have a set up like the screen shots in this example, if so then the url will be available in that
A 404 code suggests the URL is wrong - http://topdesk-url/tas/api/login/person is the one in the API docs which is slightly different than the one you provided in the question.
The base path that you’re using and the /tas/ (this might be a username or account name etc) section is missing from your example request.
http://www.topdesk.com is not a real TOPdesk instance, it's just a website. A real TOPdesk instance's address looks like one of these:
mycompany.topdesk.net (if it is hosted in the cloud)
topdesk.mycompany.com (if it is hosted locally)
The reason why you got a 404 is because that url simply doesn't exist.

Accessing FMCSA QCMobile API

I'm building a web application that needs to search the QCMobile API using the URL endpoint their documentation provided.
API URL
The path for all API resources must start with: https://mobile.fmcsa.dot.gov/qc/services/ The following are the Endpoints
EndPoint Name Query Parameters Example
/carriers/docketNumber/:docketNumber/ /carriers/docketNumber/1515?webKey=jk+k...
My URL is:
https://mobile.fmcsa.dot.gov/qc/services/carriers/docketNumber/402573?webKey=1a7649929fa2....
But I get this json response:
{"links":[],"content":"There is no resource for path /qc/services/carriers/docketNumber/402573"}
Any help would be greatly appreciated.
Kevin
It could be that the endpoint name listed on the specs page isn't correct for docketNumber. I tried your link with my webkey and it didn't work for me either. I replaced "docketNumber" with "docket-number" and I got a complete response.
https://mobile.fmcsa.dot.gov/qc/services/carriers/docket-number/402573.xml?webKey=xxxxx

Add file programmatically to IBM Connections Community

I am trying to upload files programmatically to an IBM Connections Community File library.
I am able to upload to files and then share with the community, but unfortunately is not the desired behavior.
I followed the API documentation (http://www-10.lotus.com/ldd/lcwiki.nsf/xpAPIViewer.xsp?lookupName=IBM+Connections+5.0+API+Documentation#action=openDocument&res_title=Creating_community_files_ic50&content=apicontent)
I am sending a POST to this URL: /files/basic/api/community/{community_uuid}/introspection
I tried using a file Atom Entry document, and Content-Type:application/atom+xml
But it's not working and giving me a 405 with following error:
UnsupportedOperation
-> Request sent
POST /files/basic/api/community/00f04081-f000-4752-bd88-8b73d281fb19/introspection
Content-Type: application/atom+xml
<?xml version='1.0' encoding='UTF-8'?>
<entry
xmlns:thr='http://purl.org/syndication/thread/1.0'
xmlns:opensearch='http://a9.com/-/spec/opensearch/1.1/'
xmlns:snx='http://www.ibm.com/xmlns/prod/sn'
xmlns:td='urn:ibm.com/td'
xmlns='http://www.w3.org/2005/Atom'>
<td:label>test-restore20</td:label>
<title type="text">test-restore2</title></entry>
I tried using the same method than for stand alone file, with a basic header but still giving me a 405 with following error:
UnsupportedOperation
-> Request sent:
POST /files/basic/api/community/00f04081-f000-4752-bd88-8b73d281fb19/introspection
Content-Type: binary/octet-stream
X-Update-Nonce:<Nonce>
Slug:TMap_Next_Book.pdf
Filename: /Users/Downloads/TMap_Next_Book.pdf
When I upload to myfile, works fine
-> request sent:
POST https://greenhouse.lotus.com/files/basic/api/myuserlibrary/feed
X-Update-Nonce: <Nonce>
Slug: test-restore2
Content-Type: application/binary
Filename: /Users/Downloads/client-error-log.zip
I tried the Playground, but not well documented for that part, so so far no success.
Any of you were able to do that, and would be able to share the solution?
Thanks.
Rightfully this document should be called working with IBM Connections Community Files
http://www-10.lotus.com/ldd/lcwiki.nsf/xpAPIViewer.xsp?lookupName=IBM+Connections+5.0+API+Documentation#action=openDocument&res_title=Creating_community_files_ic50&content=apicontent
The introspection endpoint should be called to get the "community collection document feed"
it doesn't look like you have the URL parameter which is required. You should use the URL with a GET /files/basic/api/community/3a246a15-b4d6-44e1-a01d-1c3d89f1f9a4/introspection?communityUuid=3a246a15-b4d6-44e1-a01d-1c3d89f1f9a4
Then you'll look for
Community Collection
Documents Feed
/
You'll then POST your file to the href --- https://greenhouse.lotus.com/files/basic/api/collection/e78ba00e-cee6-460f-a9ee-0350bf344e0b/feed
I've asked the team to change the title of the page.