Copy link to clipboard
Copied
Hello everyone,
I have a free tier of the PDF service and have successfully converted Word documents via the REST API by using the internal (adobe) storage (with Postman). Now I wanted to convert a document from SharePoint Online using JavaScript and fetch command. The query looks like this:
fetch('https://pdf-services-ew1.adobe.io/operation/createpdf', {
method: "POST",
headers: {
"Authorization": token,
"x-api-key": apiKey,
"Content-Type": "application/json",
},
body: JSON.stringify({
input: {
"uri": "https://mytenant.sharepoint.com/documents/MyDoc.docx",
"storage": "SHAREPOINT"
}})
});
I get the following answer:
{
"error":
{
"code":"BAD_PARAMS",
"message":"Not able to infer an input media type. Check the provided input and try again."
}
}
I assume that it is an error that the Sevrice cannot simply access the file, because logically it has no access. The question I have is, what do I have to do so that the PDF service can read this file? I have searched the whole internet yesterday and today (at least it feels like that) and have not gotten an answer. There is also nothing on the Adobe documentation page. What am I doing wrong? Can someone please help me?
I don't want to do this via the PowerPlatform connector. Because this works well. The question really refers to "direct" access.
Copy link to clipboard
Copied
All the cloud storage systems we support have SDKs/API calls that let you create 'readable' and 'writeable' urls for resources. Basically, "Given this path, give me a URL that is anonymously readable." You will need to look into the Sharepoint SDK to see how this done. We don't document it as it's specific to the cloud storage provider.
Copy link to clipboard
Copied
Okay, thanks for the answer. That's a really important point. Because I can't share the internal files with "the whole world". But whatever. Just for the interest of it, I created a document and shared it with "everyone". That means if someone knows the URL, he/she can download the file.
And when I run the same code as above, I get this error message with this file:
"Not able to infer an input media type. Check the provided input and try again."
And yes, in the incognito tab/window I get the "Download" dialog
Copy link to clipboard
Copied
To be clear, all the cloud storage providers let you create URLs with expirations. Most should also allow you to remove the URL when done. This is pretty standard. And it's a unique URL, so yes, it may allow anonymous reading, it won't be something people can guess. And finally, if it really bothers you, don't forget you can *copy* the file from the cloud locally and then send it to us that way. That feels like overkill, but you have options.
To your last error, it may be the way you generated the URL. When you click it, it should download the file, NOT open up Sharepoint and render the file. There's two kinds of sharable URLs, one that's "in context", for example, on Dropbox it would show the DB user interface and stuff, and the file. Or a link *directly* to the file itself.
Copy link to clipboard
Copied
You can specify an expiration date when sharing, but this functionality (share with anyone) must be allowed tenant wide at all. Almost nobody will set this in the tenant/site.
In the beginning I thought that I might have to provide an app from you in my tenant, which gets access to the SharePoint (like the "Adobe Document Cloud" app). And you then make internal queries to access this URL/File.
By the way, what I did is exactly about sharing (with everyone). And when I provide the link that SharePoint generates for me to your API, it shows an 'URL INVALID' error. I think it's because of a link like 'https://tenant.sharepoint.com/:w:/g/E...wBg5aRnu_SYA?e=ZBbsr6' (specifically, the part '/:w:/'). Yes, this link would display the file in the browser. But with the additional parameter '&download=1,' the file is directly downloaded.
Therefore, I then used this link: https://tenant.sharepoint.com/_layouts/15/Download.aspx?SourceUrl={DocumentPath}
And yes, this link also works in the "new incognito window." It's NOT a web view; the file is directly downloaded, just like when I click the "Download" button.
I am, of course, aware that I can also "save" the file with you. But there is a reason why I want to use my "own storage," isn't there?
I guess you as developers and providers of this function have tested it, and you can provide me with some code examples or explain how I can configure it.
Copy link to clipboard
Copied
"I am, of course, aware that I can also "save" the file with you. But there is a reason why I want to use my "own storage," isn't there?"
Right, but you don't seem to be happy with creating a link though. 🙂 To be clear, Adobe needs a way to read the data, and it can't login as you, so creating a temporary readable URL is fairly common and not something unexpected with APIs like this, in my opinion of course.
I haven't generated Sharepoint URLs in a long time, but the Download part just doesn't seem right. Can you share the code where you are generating your readable links?
Copy link to clipboard
Copied
I am well aware that access to a file is necessary. Thats why my suspicion was whether I might have forgotten to configure something so that Adobe can access it (e.g., with a specific Adobe app permission, similar to the "Adobe Document Cloud" app).
But, as mentioned, I activated this feature in my test tenant to try out your service. I did NOT generate the URL through an API but rather through the SharePoint UI. Share Document ==> Link ==> Allow Anyone to edit with this link. See screen:
The result of the URL looks like this (I appended the Download=1 parameter):
https://tenant.sharepoint.com/:w:/s/{SITE_NAME}/{CODE}?e={ANOTHER_CODE}&download=1
When I send this LINK to the Adobe PDF Service, I get an error messagem that the URL is invalid or not supported.
If I use this link:
https://tenant.sharepoint.com/sites/{SITE_NAME}/_layouts/15/download.aspx?SourceUrl={PATH_TO_FILE}
I receive the same Media-Type error as mentioned before.
BOTH links work in incognito mode. And I have now specifically copied these two links into a different PDF service (not Adobe), and there it works without any problems.
Copy link to clipboard
Copied
I know we apply a string matcher on the URLs, and it's possible we do NOT allow the links as you have made them, but only allow them per how the SDK makes em. From what I see in the docs, the only thing mentioned is tenant.sharepoint.com... although looking now, the docs show <tenant>.sharepoint.com. I bet if you used the SDK, which is the expectation, it's going to be something.sharepoint.com instead.
My suggestion now is - and since you would need to do this anyway - make a quick script that uses the SDK and look at the URLs generated.
Copy link to clipboard
Copied
but could you clarify the differnece between:
tenant.sharepoint
<tenant>.sharepoint.com
and something.sharepoint.com?
I want to mention that my link examples are also in the format of "something.sharepoint.com."
But okay, here is the result from SDK:
And yes, this is the same syntax. You know, the one that hasn't been working since the first post...
Or do you have your own SDK for SharePoint from Adobe?
Copy link to clipboard
Copied
We don't have a special SDK or anything. If you feel comfortable doing so, if you can directly share with me the code you use to generate the link, I can try it here and see if I get the same error. My email is jedimaster@adobe.com.
Copy link to clipboard
Copied
So, in SharePoint you have several options for creating something.
There is the server-side object model (SSOM). But this is only for on-premises. Then there is the SP Management Shell, with which you can do much more than via SSOM or the interface. But this is also only for on-premises.
In SP Online (and also possible in On-Premises) you therefore use:
Client Server Object Model (CSOM). This is also the SDK. There is also the SharePoint Online Management Shell (only for SPO). Of course, there is also the REST API, which usually has a similar range of functions to CSOM. But often can/has less. The easiest way is to use PnP PowerShell to access SharePoint using CSOM and the API. It also includes many Teams cmdlets or other M365 products. PnP PowerShell uses CSOM (=SDK) internally.
Here is a guide on how to set it up: (Note: at least PowerShell v7.2 required): https://pnp.github.io/powershell/articles/installation.html
These are the commands to generate a anonymous link:
Import-Module PnP.SharePoint
Connect-PnPOnline -Url "https://yourtenant.sharepoint.com/sites/yoursite"
Add-PnPFileAnonymousSharingLink -FileUrl "/sites/yoursite/yourLib/yourDoc.docx" -ShareType Edit
$link = Get-PnPFileSharingLink -FileUrl "/sites/yoursite/yourLib/yourDoc.docx"
$link.Link
Here ist the documentation for this command: https://pnp.github.io/powershell/cmdlets/Add-PnPFileAnonymousSharingLink.html
If CSOM cannot do something, then it uses REST-API or vice versa.
Is that enough for you?
BTW: This Microsoft article recommends using the PnP components: https://learn.microsoft.com/de-de/archive/blogs/vesku/external-sharing-api-for-sharepoint-and-onedri...
Copy link to clipboard
Copied
Hey @Seryoga89 is your issue resolved? because I am also facing the same thing and there is no reference for SharePoint in the documentation.
Copy link to clipboard
Copied
Hi @Bhupendra35330800krlj Unfortunately, no! I haven't heard from @Raymond Camden since my last reply
Copy link to clipboard
Copied
Unfortunately I've been swamped the last few days and will be the next few days. I'd like to help with this, but I can't until next week. @Bhupendra35330800krlj As stated, we don't document how to use cloud storage SDKs as that's not our area of concern per se, it's up to each provider.
Copy link to clipboard
Copied
I also run into this issue. If I click on the link, it does directly download the file.
Maybe the validation logic is a little too strict to verify that it is indeed a sharepoint link?
From example in Adobe docs:
Generated using Microsoft Graph API:
https://aaa.sharepoint.com/personal/bbb/_layouts/15/download.aspx?UniqueId=XXX&Translate=false&tempa...",
Find more inspiration, events, and resources on the new Adobe Community
Explore Now