Skip to main content
Participating Frequently
February 2, 2024
Question

How can I use the PDF Service API with SharePoint Online as external storage (not PowerPlatform)?

  • February 2, 2024
  • 2 replies
  • 3935 views

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.

    This topic has been closed for replies.

    2 replies

    Participant
    February 8, 2024

    Hey @Seryoga89  is your issue resolved? because I am also facing the same thing and there is no reference for SharePoint in the documentation.

    Seryoga89Author
    Participating Frequently
    February 8, 2024

    Hi @Bhupendra35330800krlj Unfortunately, no! I haven't heard from @Raymond Camden  since my last reply

    Raymond Camden
    Community Manager
    Community Manager
    February 8, 2024

    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. 

    Raymond Camden
    Community Manager
    Community Manager
    February 2, 2024

    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.

    Seryoga89Author
    Participating Frequently
    February 2, 2024

    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

    Raymond Camden
    Community Manager
    Community Manager
    February 2, 2024

    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.