gsureshqa / LogicApp

2 stars 0 forks source link

Json error in email attachment logic apps #3

Open joanslow opened 6 years ago

joanslow commented 6 years ago

The notes app is installed & running successfully. However both email attachment apps fail with the error "InvalidTemplate. Unable to process template language expressions in action 'CreateAzureBlob' inputs at line '1' and column '2769': The template expects its parameter to be a string or an XML. The provided value is of type 'Object'. Please see https://aka.ms/logicexpressions#json for usage details."

Please could you advise how to get them working? Many thanks.

attachmentlogicapperror

anilvem1 commented 6 years ago

Please replace the below line via Logic App -> Code View OLD: "name": "@{concat(concat(items('Foreach')?['activitymimeattachmentid'], ''), json(items('For_each')?['attachmentid'])['filename'])}"

NEW: "name": "@{concat(items('Foreach')?['activitymimeattachmentid'], '', items('For_each')?['attachmentid']?)['filename']}"

We will soon publish the updated Logic App.

joanslow commented 6 years ago

Anil, Thanks for the update. In the app code I found the suggested line, but with For_each_2, not For_each. However, adding your suggested line prevents the code from being saved. Moving the final bracket as below, allows for save:

"name": "@{concat(items('For_each2')?['activitymimeattachmentid'], '', items('For_each_2')?['attachmentid']?['filename'])}"

However, it is still sometimes failing with the same error. The only other line referencing json is

"body": "@base64ToBinary(json(items('For_each_2')?['attachmentid'])['body'])",

Many thanks, Jo

On 7 June 2018 at 17:29, Anil Kumar MSFT notifications@github.com wrote:

Please replace the below line via Logic App -> Code View OLD: "name": "@{concat(concat(items('Foreach')?['activitymimeattachmentid'], ''), json(items('For_each')?['attachmentid'])['filename'])}"

NEW: "name": "@{concat(items('Foreach')?['activitymimeattachmentid'], '', items('For_each')?['attachmentid']?)['filename']}"

We will soon publish the updated Logic App.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/gsureshqa/LogicApp/issues/3#issuecomment-395483509, or mute the thread https://github.com/notifications/unsubscribe-auth/AJiPSxqwby1snXjc65b1PU6v-NyILiZ9ks5t6VTPgaJpZM4T7rFI .

anilvem1 commented 6 years ago

Yes please. Replace the other line also. Just remove json ahead. replace the line OLD: json(items('For_each')?['attachmentid'])['filename'] NEW: items('For_each')?['attachmentid']['filename']

rerklin commented 6 years ago

Hi Anil,

I was getting the same issues as Jo but your last post has changes that don't seem to be working. I updated to: OLD: "@base64ToBinary(json(items('For_each')?['attachmentid'])['body'])", NEW: "@base64ToBinary(items('For_each')?['attachmentid']['filename'])",

However, I am still getting the following error when running it: image

Thanks! Ryan

anilvem1 commented 6 years ago

Please use the below. This has the updated code using CRM Web API.

https://github.com/anilvem1/LAMoveCRMAttachmentsToBlob-API

rerklin commented 6 years ago

Ok, I'll have to go through this new setup tomorrow as I have to read more about setting up this CRM Web API.

Thanks!

rerklin commented 6 years ago

Is there any way to just update what I already have or will that not work with Dynamics 365 v9? I just want to move over all existing email attachments after adding "Attachment Management". This looks like a lot of work for something I will just run once.

Thanks for your work!

anilvem1 commented 6 years ago

NEW: "@base64ToBinary(items('For_each')?['attachmentid']['body'])",

Replace filename with body

rerklin commented 6 years ago

Thanks Anil! That worked perfectly.

One last question, with the $top parameter. Is there a limit to the number you'd recommend putting there? I have about 100,000 email attachments to move. They're not large in size, but there are a lot. Most likely email signature files.

Thanks Again!

Ryan

anilvem1 commented 6 years ago

You can remove $top statement. Go to LA designer -> GetAttachments action -> ... -> settings -> enable paging and give count as you desire (preferred 5k or 10k) and click Save Save LA and run.

rerklin commented 6 years ago

Thanks Anil, I'll give that a try. For now though, I just shortened the recurrence and it's going along.

I did run into another issue though, I am getting an error "A record with matching key values already exists.". Any ideas? image