My main objective is to upload .pptx/.docx/.pdf file to Microsoft Sharepoint using Microsoft Graph API.
Am able to upload to simple text files using the below "PUT" request, where the content-type is multipart/form-data
https://graph.microsoft.com/v1.0/drives/{drive-id}/root:/{simple.txt}:/content
But for .pptx/.docx/.pdf files, although am getting response as "200 ok", but no file is getting creating in sharepoint site document.
I have correctly configured File type with "File" as the key and selected the appropriate file in the value of the body of the request in postman.
Observation -> While uploading txt file, the response is "201 created" and the contents of the uploaded files is getting changed. For example, if the content was "Hello there". The upload file content is,
----------------------------404518839734975569926100
Content-Disposition: form-data; name="File"; filename="sample.txt"
Content-Type: text/plain
Hello there
----------------------------404518839734975569926100--
Can someone explain what's going on here and how to upload pptx/doc/pdf file in sharepoint using MS Graph API's.
You could upload the .docx file using Graph API in post man like this.
PUT drives/{drive-id}/root:/fileName.docx:/content
In Body, choose binary type.
Related
I'm using the Tableau REST API to get an image of a workbook view.
Testing the endpoint in Postman, I get the image perfectly fine back and the Content-Type is "image/png". Now I want to send that same image to an email with an ADF pipeline, the response I get seems to be binary from the Web activity:
"{ Response": "�PNG\r\n\u001a\n\u0000\u0000\u0000\rIHDR\u0000\u0000\u0003�\u0000\u0000\u0003 ...})
I've been seeing online that the above response is of : "application/octet-stream". Even though the content-type response is of "image/png" in the response in ADF AND Postman.
So I create another web activity which is a Send Email Web activity. In the body, I send the data in a JSON format to a Logic App Send email task.
I want to embed the image into the email using the "img" HTML tag. I set the response of the Tableau image and send it with basee64 encoding:
#json(concat('{"emailAddress": "myemail#email.com", "subject": "Tableau Data","messageBody":"<img src=\"data:image/png;base64,',base64(activity('Get View').output.Response),'\" >"}'))
Once it sends it, I get no image at all.
What do I need to do in order to get the image on the email? I feel like I'm missing some encoding to the response or do I need to save it first to a storage blob and then send from there?
I'm having some trouble while trying to send a PDF file to Microsoft's Form Recognizer service.
Instead of sending the PDF Url location, I need to send the PDF file. On my experience, sending files could be done using base64 but it seems that Microsoft service is not compatible with base64 format. Whenever I try sending the file the server responses:
{
"error": {
"code": "1000",
"message": "Invalid input file."
}
}
I need to know how I should convert my PDF to the required application/pdf "Binary PDF data". I can't find any documentation referring to this conversion.
The Form Recognizer API webpage is: https://brazilsouth.dev.cognitive.microsoft.com/docs/services/form-recognizer-api-v2-1-preview-3/operations/AnalyzeWithCustomForm
And here you can find the complete documentation webpage: https://learn.microsoft.com/en-us/azure/cognitive-services/form-recognizer/quickstarts/client-library?tabs=preview%2Cv2-1&pivots=programming-language-rest-api
Thanks!
You are correct that base64-encoded requests are not supported.
If you are using curl and you want to send a local file, run this:
curl -i https://{endpoint}/formrecognizer/v2.1-preview.3/custom/models/{modelId}/analyze -H 'Content-Type: application/pdf' \
-H 'Ocp-Apim-Subscription-Key: {subscription key}' --data-binary #/path/to/your/file.pdf
The key parts are the Content-Type header, which must match a supported value, and the --data-binary flag, which is the path to a local PDF file. Be sure to include the -i flag so that you can see the Operation-Location header in the response, which is where you can retrieve the analyze results.
You may also want to take a look at the Form Recognizer SDKs for C#, Java, JavaScript, and Python.
Since DocuSign API have limitations on the max size of 25 MB per request, we have to split our envelope creation into multiple request, initially the envelope will be created as draft. Then the documents will be updated to the same envelope using envelope Documents update call.
However we are getting a 'FORMAT_CONVERSION_ERROR' error for each Word doc I add using multi part request. PDF docs can be added successfully
"errorDetails": {
"errorCode": "FORMAT_CONVERSION_ERROR",
"message": "The data could not be converted."
}
Is there a work around to make it work for multi-part request?
Here are the steps I followed:
I am creating envelope(without documents) in the first POST API call(https://demo.docusign.net/restapi/v2/accounts/{accountid}/envelopes)
Adding documents(both pdf and docx) to the envelope (multipart method) by making PUT API call for each document(https://demo.docusign.net/restapi/v2/accounts/{accountid}/envelopes/{envelopeId}/documents/{docId})
Only PDF files are uploaded to the docusign, whereas getting 400 error "FORMAT_CONVERSION_ERROR - The data could not be converted" error for docx type file upload
I am adding this header "Content-Disposition", "file; filename={filename};fileExtension={ext};documentId={id}"
Any suggestion/solution will be appreciated.
Log details:
PUT https://demo.docusign.net:7801/restapi/v2/accounts/{myaccountid}/envelopes/{myenvelopeid}/documents/1
TraceToken: d0d9eae1-01d3-4c56-928d-da38a7ac30fc
Timestamp: 2020-01-09T08:48:52.7616114Z
Content-Type: multipart/form-data; boundary=LV-qEHBRJq6zprmD52mUZfeNsrT5alHGfkE8w
Content-Disposition: file; filename=MyTemplate.docx; fileExtension=docx; documentId=1
Content-Length: 12998
Connection: Keep-Alive
Transfer-Encoding: chunked
Authorization: bearer [omitted]
Expect: 100-continue
Host: demo.docusign.net
User-Agent: Apache-HttpClient/4.0.3(java 1.5)
X-SecurityProtocol-Version: TLSv1.2
X-SecurityProtocol-CipherSuite: ECDHE-RSA-AES256-GCM-SHA384
x-forwarded-for: 106.51.84.53
--LV-qEHBRJq6zprmD52mUZfeNsrT5alHGfkE8w
Content-Disposition: form-data; name="MyTemplate.docx"; filename="MyTemplate.docx"
Content-Type: application/octet-stream
Content-Transfer-Encoding: binary
//Some binary data here.
--LV-qEHBRJq6zprmD52mUZfeNsrT5alHGfkE8w--
400 BadRequest
Content-Type: application/json; charset=utf-8
Content-Length: 96
X-DocuSign-TraceToken: d0d9eae1-01d3-4c56-928d-da38a7ac30fc
{
"errorCode": "FORMAT_CONVERSION_ERROR",
"message": "The data could not be converted."
}
Few things to check:
Does this happen with any word document or just a specific one?
Can you upload the same Word document directly to DocuSign web app and it works fine?
how large is the file in question? Is it possible it's still over 25M?
Consider using binary file transfer. Here is an example of code showing you how to do this:
https://developers.docusign.com/esign-rest-api/code-examples/code-example-send-binary
You can use multi-part mime encoding of the envelope with the individual files either BASE64 encoded or sent in binary format.
Check that you're using binary format and that the entire request to DocuSign is not over 25 MB.
Download and run a version of the eg-03- example software repository for your favorite language. These repos are stored in github.com/docusign they are documented here: https://developers.docusign.com/esign-rest-api/code-examples/code-example-send-binary.
Within the example code, workflow #10 shows how to send in binary mode. The example sends a Word document so you can substitute your own to check that it works ok.
I am using googleAPI and Nodjs to fetch mails in details using oauth2.0.But I am not getting email's signature with image attached format.What is API to fetch incoming email with signature as image attached format?
A signature as an image is incorporated by Gmail not as an attachment or inline image, but rather as a download link assigned to img src within the text/html of your message body.
Here a snippet of the response you obtain if you log the body of the message retrieved in raw format (the domain name and file ID replaced with XXX for privacy reasons):
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br clear=3D"all"><div><div dir=3D"ltr" class=3D"gmail_sig=
nature" data-smartmail=3D"gmail_signature"><div dir=3D"ltr"><img src=3D"htt=
ps://drive.google.com/a/XXXXXXXXXXXXXXXXX/uc?id=3DXXXXXXXXXXXXXXXXXX=
sYV-&export=3Ddownload"><br></div></div></div></div>
Keep in mind that the URL is quoted-printable encoded. You need to remove the soft line breaks = and replace =3D by = to obtain the correct URL - something like
https://drive.google.com/a/XXXXXXXXXXXXXXXXX/uc?id=XXXXXXXXXXXXXXXXXXsYV-&export=download
This link you can either open in your browser or access it programmatically by getting the body part of your message (filtering for Content-Type: text/html) and extracting the link e.g. with a Regex expression.
I want to download a document signed recipient using DocuSign API (REST).
I am using the following endpoint as per the documentation.
HTTP request
GET /v2/accounts/{accountId}/envelopes/{envelopeId}/documents/{documentId}
Request Headers
X-DocuSign-Authentication:{"Username": <Username>,"Password": <Password>,"IntegratorKey": <IntegratorKey>}
Accept: application/pdf
Content-Transfer-Encoding:base64
I got document in a base64 format which I am able to download but when try to open that file using PDF viewer we got the following message:
The file is blank and some error related to signature, check following screenshot
PDF open error snapshot
Are there any parameters missing while downloading the document? Please help.
Thanks.
See this link for EnvelopeId stamp control
https://support.docusign.com/en/articles/How-do-I-move-the-Envelope-ID-Stamp-on-my-documents
In DEMO environment you will always have the "demonstration only" stamp on the document. This will not be present when you goto prod environment