I want to copy embedded images from an outlook email to my blob storage. I have a step to run a For Each over the email attachments (the embedded images are recognized as attachments). But the when I look at the raw input for the email message, the attachment[0].contentBytes is Null. And the error I get when trying to create the blob using setting the blob content to "Attachments Content" is:
"InvalidTemplate. Unable to process template language expressions in action 'Create_blob' inputs at line '1' and column '3316': 'The template language function 'base64ToBinary' expects its parameter to be a string. The provided value is of type 'Null'. Please see https://aka.ms/logicexpressions#base64ToBinary for usage details.'."
Here is the Raw Input to the "When new email arrives" step:
"Attachments": [
{
"#odata.type": "#Microsoft.OutlookServices.FileAttachment",
"Id": "12345",
"LastModifiedDateTime": "2020-11-22T07:38:19+00:00",
"Name": "footer.jpg",
"ContentType": "image/jpeg",
"Size": 13969,
"IsInline": false,
"ContentBytes": null
}
]
Any help with these steps is much appreciated. Thanks!
Please click Add new parameter and choose Include Attachments. select Yes for Include Attachments:
Related
There is no dynamic content you can get from the SurveyMonkey trigger in Power Automate except for the Analyze URL, Created Date, and Link. Is it possible I could retrieve the data with an expression so I could add fields to SharePoint or send emails based on answers to questions?
For instance, here is some JSON data for a county multiple choice field, that I would like to know the county so I can have the email sent to the correct person:
{
"id": "753498214",
"answers": [
{
"choice_id": "4963767255",
"simple_text": "Williamson"
}
],
"family": "single_choice",
"subtype": "menu",
"heading": "County where the problem is occurring:"
}
And basically, a way to create dynamic fields from the content so it would be more usable?
I am a novice so your answer will have to assume I know nothing!
Thanks for considering the question.
Overall, anything I have tried is unsuccessful!
I was able to get an answer on Microsoft Power Users support.
Put this data in compose action:
{
"id": "753498214",
"answers": [
{
"choice_id": "4963767255",
"simple_text": "Williamson"
}
],
"family": "single_choice",
"subtype": "menu",
"heading": "County where the problem is occurring:"
}
Then these expressions in additional compose actions:
To get choice_id:
outputs('Compose')?['answers']?[0]?['choice_id']
To get simple_text:
outputs('Compose')?['answers']?[0]?['simple_text']
Reference link here where I retrieved the answer is here.
https://powerusers.microsoft.com/t5/General-Power-Automate/How-to-write-an-expression-to-retrieve-answer/m-p/1960784#M114215
I'm using an indexer to index PDF files into an Azure Search Index. I have some metadata parameters encoded as URL-safe base64 (document_url in the screenshot):
Everything works fine. The indexer runs and the document_url is decoded and indexed in a Url property.
The problem comes when I try to do the same for a metadata_title parameter. Configured in exactly the same way as 'document_url', when the indexer runs it throws an error.
Message: Could not parse document. Could not apply mapping function 'base64Decode' to field 'metadata_title'.
Details: The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or an illegal character among the padding characters.
The metadata_title has the following value: Tm9uLVNtb2tlcsKQcyBEZWNsYXJhdGlvbg
Using an external tool I'm able to decode that without issues.
The mapping configuration for both 'document_url' and 'metadata_title' are the same:
{
"sourceFieldName": "metadata_title",
"targetFieldName": "MetaTitle",
"mappingFunction": {
"name": "base64Decode",
"parameters": {
"useHttpServerUtilityUrlTokenDecode": false
}
}
}
Even if I remove the 'metadata_title' property from the blob, it keeps throwing the same error.
Maybe the problem is in the Index?
This is where the metadata_title is being mapped:
{
"name": "MetaTitle",
"type": "Edm.String",
"searchable": true,
"filterable": false,
"retrievable": true,
"sortable": false,
"facetable": false,
"key": false,
"indexAnalyzer": null,
"searchAnalyzer": null,
"analyzer": null,
"normalizer": null,
"synonymMaps": []
}
This property is searchable, while Url (the property where 'document_url' is being mapped) is not. That's the only difference I can see.
'metadata_title' is one of the reserved metadata properties for PDFs when using the blob indexer with "parsingMode": "default" and "dataToExtract": "contentAndMetadata", so I suspect what is happening is that the property that is attempting to be decoded is the one that ACS extracted from your document (which is not base 64 encoded) and not the one from your blob's metadata. To get around this, you could need to rename the blob metadata field to have a name that is not one of the reserved properties that ACS extracts on your behalf. If that is not feasible, please open a support ticket so that one of our engineers can work with you on a more custom solution.
I'm using graph API mentioned below -
"client.api(/users/${data_body.payload.originEmail}/messages/${data_body.payload.emailId}/attachments/${data_body.payload.attachmentId}/$value).getStream()"
it works fine for me if attachment type is "fileattachment" but this api is not working in case of "referenceattachment"
also I went through the documentation it says that "Attempting to get the $value of a reference attachment returns HTTP 405."
and it does not return contentBytes
enter image description here
site to refer - https://learn.microsoft.com/en-us/graph/api/attachment-get?view=graph-rest-1.0&tabs=http
1: https://i.stack.imgur.com/fGrft.png
does anyone have any solution to get content data of reference attachment. if yes it would be great help !! Thanks in advance
GET /drive/items/{item-ID}?select=id,#microsoft.graph.downloadUrl
response =>
click to open
Here you can see downloadURL is missing in response
The graph v1.0 endpoint doesn't have any support for reference attachments (other then showing you that one existing on an email). You need to switch to the beta endpoint which will provide the sourceUrl of the attachment in question eg
https://developer.microsoft.com/en-us/graph/docs/api-reference/beta/resources/referenceattachment
eg
https://graph.microsoft.com/beta/me/mailfolders/inbox/messages/..AA=/attachments/AAM..
would give you something like
{
"#odata.context": "https://graph.microsoft.com/beta/$metadata#users('..')/mailFolders('inbox')/messages('..')/attachments/$entity",
"#odata.type": "#microsoft.graph.referenceAttachment",
"id": "..",
"lastModifiedDateTime": "2022-04-11T23:53:54Z",
"name": "User1.text",
"contentType": "application/octet-stream",
"size": 565,
"isInline": false,
"sourceUrl": "https://..-my.sharepoint.com/personal/.._com/Documents/Attachments/User1.text",
"providerType": "oneDriveBusiness",
"thumbnailUrl": null,
"previewUrl": null,
"permission": "other",
"isFolder": false
}
You then need to take the sourceURL and download that via the applicable API for the reference attachment. eg in this example its Sharepoint so you can use the SharePoint API to download the file.
I am trying to save a google drive file with custom properties, but its not working and due to the very poor documentation of the Google API, i am struggeling with this. Here is my code so far:
$g = new FileCtrl();
$fileMeta = new Google_Service_Drive_DriveFile();
$fileMeta->name = $file['name'];
$fileMeta->parents = [$g->googleDriveFolderId];
$fileMeta->appProperties = (object)['lead_id'=>$file['lid'], 'sales_package_id'=>$file['pid'], 'user_id'=>$user->uid];
//$fileMeta->size = $file['size'];
$fileData = array(
'data' => $fileContent,
'mimeType' => $file['media_type'],
'uploadType' => $file['multipart'],
);
//create file in google drive
$res = $g->client->files->create($fileMeta, $fileData);
It is not returning an error and the event is saved, but without the custom properties!?
You are probably looking for the properties in the returned file resource.
The reason they aren't there is that Drive only returns a small number of the file properties (name, mime type, id). If you want to see the full file resource you need to include fields=* in the request. So a correct request would look something like
POST https://content.googleapis.com/drive/v3/files?fields=*
I don't know the PHP library, so you'll need to figure that bit out. It will be something like
'fields' => '*',
I just tested this.
Request:
{
"name": "Linda Test",
"mimeType": "application/vnd.google-apps.document",
"appProperties": {
"TestingId": "1"
}
}
Response:
{
"kind": "drive#file",
"id": "1mhP2EW4Kbl81F5AuJ4zJ2IPoeI56i_Vd5K-dfGJRj6Y",
"name": "Linda Test",
"mimeType": "application/vnd.google-apps.document"
}
Do a file.get to check the file metadata.
{
"kind": "drive#file",
"id": "1mhP2EW4Kbl81F5AuJ4zJ2IPoeI56i_Vd5K-dfGJRj6Y",
"name": "Linda Test",
"mimeType": "application/vnd.google-apps.document",
"starred": false,
"trashed": false,
"explicitlyTrashed": false,
"parents": [
"0AJpJkOVaKccEUk9PVA"
],
"appProperties": {
"TestingId": "1"
},
...
}
I suggest you check your uploaded file using the File.get method after its returned to be sure that it was added. To my knowledge there is now way to see these added fields via the Google drive website interface. If after ruining a file.get you still find that it wasn't uploaded i suggest you log this as a bug with the Google APIs PHP client library team. This works with raw rest requests it could be an issue with the library.
Met problem when using Mandrill API to send transactional newsletters. I chose Handlebars for the template parameters. The user name was shown correctly, but data in the list (post titles) were empty. Please help indicate if anything I did wrong. Thank you!
The template is as below, sent to the endpoint /messages/send.json :
func genHTMLTemplate() string {
return "code generated template<br>" +
"Hi {{name}}, <br>" +
"{{#each posts}}<div>" +
"TITLE {{title}}, THIS {{this}}<br>" +
"</div>{{/each}}"
}
The API log in my Settings panel in mandrillapp.com shows the parameters:
{
"key": "xxxxxxxxxx",
"message": {
:
"merge_language": "handlebars",
"global_merge_vars": null,
"merge_vars": [
{
"rcpt": "xxxxxx#gmail.com",
"vars": [
{
"name": "posts",
"content": [
{
"title": "title A"
},
{
"title": "title B"
},
]
},
{
"name": "name",
"content": "John Doe"
}
]
}
],
:
},
:
}
And below is the email received. "title A" and "title B" are expected after "TITLE".
code generated template
Hi John Doe,
TITLE, THIS Array
TITLE, THIS Array
Mandrill decided to create custom handlebars helpers with some horrible, HORRIBLE names:
https://mandrill.zendesk.com/hc/en-us/articles/205582537-Using-Handlebars-for-Dynamic-Content#inline-helpers-available-in-mandrill
title and url will definitely give you grief if your objects happen to have keys named title and urlas well. Why they didn't name their helpers something like toTitleCase and encodeUrl is beyond me.
As far as arrays and #each is concerned, you can work around it by using {{this.title}} instead of {{title}}.
After testing with Mandrill's sample code here I found the key "title" just doesn't work. Dunno the reason (a reserved keyword of Mandrill?) but replace it with "title1", "titleX" or something else it can be rendered correctly.
{
"name": "posts",
"content": [
{
"title": "blah blah" // "title1" or something else works
},
}
while using handlebars as the merge language 'title' is the reserved helpername which is used in handlebars which makes your text in title case. If you do only {{title}} by default it considers as title the empty text. try giving it {{title title}} which should work or changing the key name to something else ( if you dont want your title in title case )
I know this is late but it could be of use to someone trying to debug this issue currently. Take note of this point in the Mandrill documentation
There are two main ways to add dynamic content via merge tags: Handlebars or the Mailchimp merge language. You may already be familiar with the Mailchimp merge language from creating and editing Mailchimp templates. We also offer a custom implementation of Handlebars, which is open source and offers greater flexibility.
To set your merge language, navigate to Sending Defaults and select Mailchimp or Handlebars from the Merge Language drop-down menu.
I've run into a similar issue on Sending Blue, where their default configuration does not enable handle bars so it won't evaluate them.