Azure Logic App - On New Email - Attachments have null bytes - azure-logic-apps

Why aren't the attachments being read correctly?
Trying to use the quick-start template for saving attachments in emails to a SharePoint folder.
Workflow:
On new email (success)
For each container (Attachments is passed in)
Create file (fails)
On new email > Outputs > Attachments
On new mail appears to succeed, but the content of the attachments is set to null ("ContentBytes": null):
[
{
"Id": "AAMkADlhMDBiODNiLWFmOTEtNGZjOS1hMjYxLTY1OTU3MDk4YzZjNABGAAAAAACijX5OkcblRIVMFzOsYgiSBwBFaJ_hCA08Tb5SmdY6ZqCxAAAAADB8AABFaJ_hCA08Tb5SmdY6ZqCxAACD6w2UAAABEgAQAOCw7xb1bG9LstW5SRafEOE=",
"ContentType": "image/jpeg",
"Size": 16962,
"#odata.type": "#Microsoft.OutlookServices.FileAttachment",
"Name": "image001.jpg",
"ContentBytes": null
},
{
"Id": "AAMkADlhMDBiODNiLWFmOTEtNGZjOS1hMjYxLTY1OTU3MDk4YzZjNABGAAAAAACijX5OkcblRIVMFzOsYgiSBwBFaJ_hCA08Tb5SmdY6ZqCxAAAAADB8AABFaJ_hCA08Tb5SmdY6ZqCxAACD6w2UAAABEgAQAG7KUOVpzCRJslBYmXAysB4=",
"ContentType": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
"Size": 194702,
"#odata.type": "#Microsoft.OutlookServices.FileAttachment",
"Name": "Test.docx",
"ContentBytes": null
},
{
"Id": "AAMkADlhMDBiODNiLWFmOTEtNGZjOS1hMjYxLTY1OTU3MDk4YzZjNABGAAAAAACijX5OkcblRIVMFzOsYgiSBwBFaJ_hCA08Tb5SmdY6ZqCxAAAAADB8AABFaJ_hCA08Tb5SmdY6ZqCxAACD6w2UAAABEgAQAL3JExHdzLJDs0YH1XpZXgU=",
"ContentType": "image/jpeg",
"Size": 73353,
"#odata.type": "#Microsoft.OutlookServices.FileAttachment",
"Name": "image005.jpg",
"ContentBytes": null
},
{
"Id": "AAMkADlhMDBiODNiLWFmOTEtNGZjOS1hMjYxLTY1OTU3MDk4YzZjNABGAAAAAACijX5OkcblRIVMFzOsYgiSBwBFaJ_hCA08Tb5SmdY6ZqCxAAAAADB8AABFaJ_hCA08Tb5SmdY6ZqCxAACD6w2UAAABEgAQABUsTq9cXiVCoowGEFnbtHw=",
"ContentType": "image/jpeg",
"Size": 3684,
"#odata.type": "#Microsoft.OutlookServices.FileAttachment",
"Name": "image003.jpg",
"ContentBytes": null
}
]
For-each container > Create file
Fails with the following:
InvalidTemplate. Unable to process template language expressions in
action 'Create_file' inputs at line '1' and column '11': '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.'.

There's an "include attachments " option on the trigger to opt in to include bytes. Make sure that is turned on and it should work.

Related

How to create string variable from array in Azure LogicApps?

I have LogicApp which get HTTP Post from Azure Alerts.
I would like to create "DimensionNames" string variable, which includes all names in array.
DimensionNames value could be "name1,name2, name3, name4".
Finally I would use DimenstionNames string in "call Webhook".
How do it?
Request Body Json in "When a HTTP request is received"
{
"dimensions": {
"items": {
"properties": {
"name": {
"type": "string"
},
"value": {
"type": "string"
}
},
"required": [
"name",
"value"
],
"type": "object"
},
"type": "array"
}
}
Using variables and Join action you can convert array to a string variable. I have reproduced from my side and below are steps I followed,
Created an alert and configured a HTTP trigger logic app to it.
Designer of logic app will be,
The payload of http request is,
{
"dimensions": {
"items": {
"properties": {
"name": {
"type": "string"
},
"value": {
"type": "string"
}
},
"required": [
"name",
"value"
],
"type": "object"
},
"type": "array"
}
}
4. Next taken Initialize variable action as shown below,
Taken Join action to divide values from array with comma,
Next taken another initialize variable action to store value as a string,
In webhook action the value of string variable is used as body,
Outputs are shown below,
Http trigger:
Output of initialize variable,
Output if Join,
Output of initialize variable 2,
Reference link

Reading message from Service bus

I have a logic app with started when there is a message in serviceBus queue. The message is being published to the service bus from the DevOps pipeline using "PublishToAzureServiceBus" as a JSON message or from the pipeline webhook.
But getting an issue while converting a message from service bus to original JSON format, not able to get valid JSON object. It's getting append with some Serialization object.
I have tried with base64 decode, and JSON converts but have not been able to get success.
Below is the content of the message it looks like.
Any pointer on how can solve this?
Sample message sent
{
"id": "76a187f3-c154-4e60-b8bc-c0b754e54191",
"eventType": "build.complete",
"publisherId": "tfs",
"message": {
"text": "Build 20220605.8 succeeded"
},
"detailedMessage": {
"text": "Build 20220605.8 succeeded"
},
"resource": {
"uri": "vstfs:///Build/Build/288",
"id": 288,
"buildNumber": "20220605.8",
"url": "https://dev.azure.com/*******/_apis/build/Builds/288",
"startTime": "2022-06-05T14:47:01.1846966Z",
"finishTime": "2022-06-05T14:47:16.7602096Z",
"reason": "manual",
"status": "succeeded",
"drop": {},
"log": {},
"sourceGetVersion": "LG:refs/heads/main:********",
"lastChangedBy": {
"displayName": "Microsoft.VisualStudio.Services.TFS",
"id": "00000000-0000-0000-0000-000000000000",
"uniqueName": "***************"
},
"retainIndefinitely": false,
"definition": {
"definitionType": "xaml",
"id": 20,
"name": "getReleaseFile",
"url": "https://dev.azure.com/************/_apis/build/Definitions/20"
},
"requests": [
{
"id": 288,
"url": "https://dev.azure.com/B*****/**********/_apis/build/Requests/288",
"requestedFor": {
"displayName": "B*****.sag",
"id": "*******",
"uniqueName": "B**********"
}
}
]
},
"resourceVersion": "1.0",
"resourceContainers": {
"collection": {
"id": "*******",
"baseUrl": "https://dev.azure.com/B*****/"
},
"account": {
"id": "******",
"baseUrl": "https://dev.azure.com/B*****/"
},
"project": {
"id": "**********",
"baseUrl": "https://dev.azure.com/B*****/"
}
},
"createdDate": "2022-06-05T14:47:28.6089499Z"
}
Message received
#string3http://schemas.microsoft.com/2003/10/Serialization/�q{"id":"****","eventType":"build.complete","publisherId":"tfs","message":{"text":"Build 20220605.8 succeeded"},"detailedMessage":{"text":"Build 20220605.8 succeeded"},"resource":{"uri":"vstfs:///Build/Build/288","id":288,"buildNumber":"20220605.8","url":"https://dev.azure.com/*****/********/_apis/build/Builds/288","startTime":"2022-06-05T14:47:01.1846966Z","finishTime":"2022-06-05T14:47:16.7602096Z","reason":"manual","status":"succeeded","drop":{},"log":{},"sourceGetVersion":"LG:refs/heads/main:f0b1a1d2bd047454066cf21dc4d4c710bca4e1d7","lastChangedBy":{"displayName":"Microsoft.VisualStudio.Services.TFS","id":"00000000-0000-0000-0000-000000000000","uniqueName":"******"},"retainIndefinitely":false,"definition":{"definitionType":"xaml","id":20,"name":"getReleaseFile","url":"https://dev.azure.com/******/_apis/build/Definitions/20"},"requests":[{"id":288,"url":"https://dev.azure.com/*****/******/_apis/build/Requests/288","requestedFor":{"displayName":"baharul.sag","id":"******","uniqueName":"baharul.*****"}}]},"resourceVersion":"1.0","resourceContainers":{"collection":{"id":"3*****","baseUrl":"https://dev.azure.com/*****/"},"account":{"id":"******","baseUrl":"https://dev.azure.com/*****/"},"project":{"id":"*******","baseUrl":"https://dev.azure.com/*****/"}},"createdDate":"2022-06-05T14:47:28.6089499Z"}
When reading message from service bus in peek mode can see as below where <#string3http://schemas.microsoft.com/2003/10/Serialization/��> is appended to json string
Publish using PublishToAzureServiceBus from Azure pipeline.
Publish from Azure DevOps project webhook
I believe what is happening is that you have two different types of serialisation in the body of the brokered message created by the PublishToAzureServiceBus task. This is because the brokered message only supports binary content.
So the json is initially serialised as a binary string using the data contract serialiser.
How to solve this? Do the following before passing to your json deserialiser - unfortunately the logic app isn't doing this:
byte[] messageContent = brokeredMessage.GetBody<byte[]>();
string messageContentStr = Encoding.UTF8.GetString(messageContent);
I probably wouldn't use a logic app to do the reading of the message because to insert c# like I suggest you're gonna need to call an azure function or similar. I'd create an azure function to read your messages as above.

Can't create a schema extension

I am trying to create a schema extension in Microsoft Graph API.
But it has failed with error message "Property type is invalid for target types".
POST https://graph.microsoft.com/v1.0/schemaExtensions
Content-type: application/json
{
"id":"extendedData",
"description": "Graph Learn training courses extensions",
"targetTypes": [
"Event"
],
"properties": [
{
"name": "courseId",
"type": "Integer"
},
{
"name": "materialId",
"type": "Integer"
},
{
"name": "courseType",
"type": "String"
}
]
}
Response
{
"error": {
"code": "BadRequest",
"message": "Property type is invalid for target types.",
"innerError": {
"date": ...,
"request-id": ...,
"client-request-id": ...
}
}
}
Why can't I create a schema extension and what error means?
Integer type in properties is not supported for Event targetTypes based on Supported property data types.
You could change them to String.
Please note that you may will encounter a new error: Attempt to update complex extension definition on application: dexxxxx5-d9f9-48b1-a8ad-b7xxxxx25064 belonging to different context.
If you get this error, it means you still need to put an owner property in the JSON payload. (If you don't get this error, it's unnecessary to put owner property)
Register an Azure AD app and put the application id as the owner.
POST https://graph.microsoft.com/v1.0/schemaExtensions
Content-type: application/json
{
"id":"extendedData",
"description": "Graph Learn training courses extensions",
"targetTypes": [
"Event"
],
"owner": "{application id of an Azure AD app}",
"properties": [
{
"name": "courseId",
"type": "String"
},
{
"name": "materialId",
"type": "String"
},
{
"name": "courseType",
"type": "String"
}
]
}

Cannot set SKU using Quickbooks API

I’m trying to create an item using the Quickbooks Online API, but the field Sku is just ignored. I send a body like this:
{
"TrackQtyOnHand": true,
"Name": "Garden Supplies",
"Sku": "ITEM-1",
"QtyOnHand": 10,
"IncomeAccountRef": {
"name": "Sales of Product Income",
"value": "79"
},
"AssetAccountRef": {
"name": "Inventory Asset",
"value": "81"
},
"InvStartDate": "2015-01-01",
"Type": "Inventory",
"ExpenseAccountRef": {
"name": "Cost of Goods Sold",
"value": "80"
}
}
However in the object I get back as response, the Sku field is not there.
I set the parameter minorVersion to 45 (which is something I was suggested to do), but still not working.
I think the problem is that the param minorVersion should actually be minorversion (all lowercase).

Docusign REST API MERGE FIELD - SALESFORCE

Im trying to prefill my document with salesforcse Lead Name, however i cant accomplish it, the signHereTabs, and dateSignedTab is showing but the
texttabs dont get any data,
The REST API Documentation https://docs.docusign.com/esign/restapi/CustomTabs/CustomTabs/create/#request
says: that the row field is the "Specifies the row number in a Salesforce table that the merge field value corresponds to." but if i pass the salesforce record id im getting the error:
DocuSign Response{
"errorCode": "INVALID_REQUEST_PARAMETER",
"message": "The request contained at least one invalid parameter. int value expected for parameter: mergeField.row"
}
This is my json request:
{
"emailSubject": "Agreement",
"emailBlurb": "MSTSolutions is sending you this request for your electronic signature and enter or update confidential payment information.Please review and electronically sign by following the link below.",
"templateId": "42a4815d-f8ac-4972-b1ea-2e1534324658",
"envelopeIdStamping": "false",
"templateRoles": [{
"roleName": "Signer 1",
"name": "TEST TEST",
"email": "xxx#xxxx.com",
"recipientId": "1",
"tabs": {
"signHereTabs": [{
"xPosition": "25",
"yPosition": "50",
"documentId": "1",
"pageNumber": "1"
}],
"dateSignedTabs": [{
"name": "Date Signed",
"xPosition": "25",
"yPosition": "100",
"documentId": "1",
"pageNumber": "1"
}],
"textTabs": [{
"tabLabel": "LeadFirstName",
"xPosition": "25",
"yPosition": "200",
"documentId": "1",
"pageNumber": "1",
"mergeField": {
"configurationType":"Salesforce",
"path":"Lead",
"row":"00Q29000003fI13",
"writeback":"true",
"allowSenderToEdit":"true",
}
}]
}
}],
"status": "sent"
}
Thanks
Fairly sure the error is is how your path is configured. Try this:
"path": "Lead.FirstName"
and then remove the "Row" line
If you use the 'GET /v2/accounts/{accountId}/envelopes' create endpoint you can pass in the lead/opportunity/account Ids via the "Custom Fields" section. This will set all custom Salesforce fields you have defined in the template (relating to the SFIDs you provide) without having to set each tab one by one.
"customFields":{
"textCustomFields":[
{
"value":"0060n00000DIvfNAAT",
"name":"Opportunity",
"configurationType":"salesforce"
}
]
}
Note the textCustomFields is enclosed in a customFields block (which matches the published API) and most importantly, the configuration type must be set to "salesforce" and the Name must be "Opportunity" (etc) without the ##SF prefix which appears in a lot of examples on the web (for the SOAP api). By examining the 'GET /v2/accounts/{accountId}/envelopes/{envelopeId}/custom_fields' endpoint you can see that the API is automatically afixing the ##SF prefix and modifying the Value to include the record name:
{
"textCustomFields": [
{
"fieldId": "10140751586",
"name": "##SFOpportunity",
"show": "false",
"required": "false",
"value": "0060n00000DIvfNAAT~Test Opp Lisa Simpson"
}
}

Resources