How can I send documents with http request to power automate? - node.js

How can I send array documents and images with an HTTP request to power automate?
I am using type script with nodejs as backend.
Please see the code I am using below:
Services.ts:
sendEmailData( Notice_ID: string, Site_Notice_ID: string,EmailAddress:
string,Issued_To: string,Issue_To_Email: string,Description: string,Documents: any){
const postData: Post = {Notice_ID:Notice_ID, Site_Notice_ID:
Site_Notice_ID,EmailAddress: EmailAddress,Issued_To:Issued_To,
Issue_To_Email: Issue_To_Email,Description:Description, Documents: Documents};
this.http.post(this.SendEmailUrl, postData).subscribe(responseData => {
console.log(responseData)
});
}
Component.ts:
sendEmail(){
// console.log(emailData)
let Description = (document.getElementById("input2") as HTMLInputElement).value
this.postsService.sendEmailData(
emailData.Notice_ID,
emailData.Site_Notice_ID,
emailData.EmailAddress,
emailData.Issued_To,
emailData.Issue_To_Email,
Description,
this.Documents)
}
Power automate HTTP received sample:
{
"Notice_ID": "39208101",
"Site_Notice_ID": "392081",
"EmailAddress": "some#emailaddress.co.za",
"Issued_To": "Jay",
"Issue_To_Email": "some#emailaddress.co.za",
"Description": "",
"Documents": [
{},
{},
{}
]
}

You wanna send documents to PWA flow, right? What is the origin format and what format do you want to save these documents in? Where do you want to save them?
I'm considering you want to send them to PWA by a post request and save it in a OneDrive Business' folder.
{
"Notice_ID": "39208101",
"Site_Notice_ID": "392081",
"EmailAddress": "some#emailaddress.co.za",
"Issued_To": "Jay",
"Issue_To_Email": "some#emailaddress.co.za",
"Description": "",
"Documents": [ {"$content-type":"application/pdf","$content":"your base64 encoded
file here"}]
}
You can take a look at the complete example: https://api.npoint.io/073b1351d9b0cd0c7f88
Then, add the key "Documents" to a variable, like this:
Create an "apply to each" action to run your "documents" list.
For each dictionary in your document list, create a file:
In the "file content" field you can put the "Current action" variable.
Don't forget to create a counter or find some other way to name your created files with different names. You can also bring them named from your application and use the JSON body below:
"Documents": [ {"filename":"myfile.pdf","file":{"$content-
type":"application/pdf","$content":"your base64 encoded
file here"}}]
And set the filename in the "Apply to each":
Change the "file content":
You can use this website for generating base64 encoded files for testing your flow: https://base64.guru/converter/encode/pdf

Related

Buffer to sign parameter is mandatory- Create Graphical Signature - DSA(DocuSign Signature Appliance) REST Web Services

Getting Error while cosuming this API(function) Create Graphical Signature
Image Attached API
CodeSample PostMan
To Create Graphical signature in your DSA you should use the following
POST https://DSA:8081/sapiws/v1/users/{{USER}}/graphical_signatures
{
"imageName" : "The Graphical Image Name",
"imageFile" : "The Graphical Signature Image Data In Base 64"
}
When {{User}} is the name of the user you want to create the graphical signature
If you want to perform sign operation, DSA Rest API allows you to sign in three different ways.
Buffer sign
Sign on a signature field
Create field and sign
Buffer sign-
PUT https://DSA:8081/sapiws/v1/digital_signature
{
"signBuffer": {
"BufferToSign": "Data"
}
}
When "Data" is your data you want to sign on, it should be encoded with Base64.
Sign on a signature field-
PUT https://DSA:8081/sapiws/v1/digital_signature
{
"signField": {
"signatureFieldName": "The Signature Name"
"file": "The PDF File Data",
"FileType": "PDF"
}
}
When the PDF file data is in Base64.
You can get the signature field name by using it like this.
POST https://DSA:8081/sapiws/v1/digital_signature
{
"getAllSignatureFields": {
"file": "The Signed File",
"FileType": "PDF",
}
}
Create field and sign-
PUT https://DSA:8081/sapiws/v1/digital_signature
{
"CreateAndSignField": {
"file": "The PDF File Data",
"fileType": "PDF"
}
}

DocuSign REST API DELETE method requires a body

For example to remove a member from a signing group you call:
/restapi/v2/accounts/1686083/signing_groups/{groupId}/users
and provide:
{
"users": [
{
"userName": "sample string 1",
"email": "sample string 2"
}
]
}
as the body
But my REST object (in ServiceNow) does not allow me to provide a body when I'm using the delete method. Am I just stuck?
I don't think there is any another way to remove the user from a SigningGroup using API. You can try to update the user in a Signing group to a Dummy Email so that original user will not get email for signing. And once in a while DS Admin can go to WEBApp and manually delete it, if Service now is not allowing DS API delete operation with a body.
If you're using RestMessageV2 in ServiceNow scripted Outbound REST, there's a setRequestBody method you can use to set the request body as a string:
Example in the docs here
var sm = new sn_ws.RESTMessageV2("Update user","post");
var body = "{ ...Message body content... }";
sm.setRequestBody(body);

Web push messaging.setBackgroundMessageHandler not working

I implemented web-push notifications on my site with Google Firebase service.
firebase.google.com/docs/cloud-messaging/js/client
I tested it and everything works fine, but when my website window isn't in focus (it's in background) or closed and if I get push-notification it will disappear after 20 seconds.
In my https://hdlava.me/j/firebase_subscribe.js file I added
requireInteraction: true
flag in messaging.onMessage so if I get push mesage when my website is open the message won't disappear until I click on it.
I tried to add this
requireInteraction: true
in messaging.setBackgroundMessageHandler in my https://hdlava.me/firebase-messaging-sw.js, but it's not working. Even:
console.log('[firebase-messaging-sw.js] Received background message ', payload)
doesn't work. It looks like whole messaging.setBackgroundMessageHandler does not work.
Can someone please help me figure out what is the problem ? Also if I use in firebase-messaging-sw.js
self.addEventListener("push",function(event)
instead messaging.setBackgroundMessageHandler so I have two messges at once. First message disappears and second one doesn't, but second one is not clickable. Is it possible to prevent first message and make second one to be clickable ?
Referring to the FCM docs:
https://firebase.google.com/docs/cloud-messaging/js/receive
"Note: If you set notification fields in your HTTP or XMPP send request, those values take precedence over any values specified in the service worker."
So, if you have
{
"notification": {
"title": "Your title",
"body": "Your message"
},
"to": "topic",
}
It never triggers the BackgroundMessageHandler. Because sending data this way, simply overrides your variables. If you want to trigger it you need to send your notification like this:
{
"data": {
"notification": {
"title": "Your title",
"body": "Your message"
}
},
"to": "topic",
}

Outlook REST API to extract URLs in the message body

Is there an Outlook REST API that gives me all the urls extracted from the body of the message? Some thing like what EWS's EntityExtractionResult does?
No there isn't. However, you can retrieve extended properties, so you should be able to request the PidNameExtractedUrls property.
If you dig through those open specs, you should find these details on PidNameExtractedUrls:
Property set: PSETID_XmlExtractedEntities {23239608-685D-4732-9C55-4C95CB4E8E33}
Property name: XmlExtractedUrls
So that would mean I could make the following request (assuming you're using the Outlook endpoint, not Graph):
GET https://outlook.office.com/api/v2.0/me/messages?$expand=SingleValueExtendedProperties($filter=PropertyId eq 'String {23239608-685D-4732-9C55-4C95CB4E8E33} Name XmlExtractedUrls')
For Graph, you would replace PropertyId with id.
That will include something like this in the message entities that have this property set:
"SingleValueExtendedProperties": [
{
"PropertyId": "String {23239608-685d-4732-9c55-4c95cb4e8e33} Name XmlExtractedUrls",
"Value": "<?xml version=\"1.0\" encoding=\"utf-16\"?><UrlSet><Version>15.0.0.0</Version><Urls><Url StartIndex=\"0\"><UrlString>https://www.google.com</UrlString></Url><Url StartIndex=\"23\"><UrlString>https://developer.microsoft.com/outlook</UrlString></Url></Urls></UrlSet>"
}
]

Is there a way to search inside a message using Gmail API?

I have thousands of email. I need to search whether any of the message contains the text "Hello world" or any other regular expression. How can I achieve this using Gmail API?
The Users.messages: list-request supports a custom query parameter that you can use. This parameter works just the same as the search input field in the regular Gmail Client.
q = Hello world
GET https://www.googleapis.com/gmail/v1/users/me/messages?q=Hello+world
Response:
{
"messages": [
{
"id": "14f9826d5e0811ee",
"threadId": "14f9826d5e0811ee"
}
],
"resultSizeEstimate": 1
}

Resources