Decrypt / Decode the content from incoming message from AWS SNS to ultra pipeline

I have received the below message from AWS SNS to my ultra pipeline, I would like to know how I can Decrypt / Decode the content from the message. Thanks
[
{
“task_name”: “xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx”,
“client_port”: 19549,
“x-amz-sns-topic-arn”: “arn:aws:sns:xxxxxxxxxxxxxxxxxxxxx”,
“connection”: “keep-alive”,
“user-agent”: “Amazon Simple Notification Service Agent”,
“x-amz-sns-message-type”: “SubscriptionConfirmation”,
“x-forwarded-for”: “xxxxxxxxxxxx”,
“host”: “partners-fm.snaplogic.io”,
“content-length”: “1606”,
“x-amz-sns-message-id”: “7dabe4e2-e211-415f-8972-eaeeb3bad1d9”,
“content-type”: “text/plain; charset=UTF-8”,
“path_info”: “”,
“method”: “POST”,
“query”: {
},
“server_ip”: “xxx.xxx.xxx.xxx”,
“client_ip”: “xxx.xxx.xxx.xxx”,
“server_port”: 8084,
“uri”: “xxxxxxxxxxxxxxxx/Deepak%20Shaw/SNSTestUTask”,
“content”: “ewogICJUeXBlIiA6ICJTdWJzY3JpcHRpb25Db25maXJtYXRpb24iLAogICJNZXNzYWdlSWQiIDogIjdkYWJlNGUyLWUyMTEtNDE1Zi04OTcyLWVhZWViM2JhZDFkOSIsCiAgIlRva2VuIiA6ICIyMzM2NDEyZjM3ZmI2ODdmNWQ1MWU2ZTI0MjVlOTBjY2Y2MjMxNTYwOWNlODhhN2FlMGRmMmFkZjFlZDQ4ZmEwN2MzMThlMGJmYjcyYzczYjlkNTQyMWMwNmM2OGQ4NTM2YTYzMzQ3ODUzNzRiODVlOTFjMzY2NWFjMzJlYTRmZWNiYWEwM2VhNjJjYTEwMjkzOGIwNTUwZmZiOWEwODNhMmU0NzdmNjI1ZmJmOTc2NjcwMjk3ZDg4Mzk3NzdjNjBjMGE5M2RlOGQ2YWFmNjRlZWMxZmRkZTIwNTJiYTVhOWM0OGU0ZWVlM2E2ZjNlZjg5YTZlZTEzNDgyNDg1MGMxIiwKIC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RRW1aU1g0Zm1OZkhadkhMcmtqb2FuN0YrRzFmVFFKeDFRb0VyZXFvQjBsYmltTGg0a292emw0MUFpUWFKVzdhOXlXRFNvKzhaRkUzL1RZT2N0U1plWWdvd1VZMUZvcmFOa1A1VTMxTHRRb2ZMK2FXOTBNQkNFUnl2SDN1MXM3c2NDayt2d3oxb2pEWlNoRVFuSUhhSTdRYWNzL0NBRHl5QWUzTDJjbEhZdll2WVdSMWsvUG9WY2ZqTER0VmNEVndsc0lWZXFrOU5EZDRsekx3QU9LTWhGUEdrQk9lRm1xYmhnMld6dUNSdVVoK2pSVlc2R2JSTWpBNjhHa3Mxd0tyV1oxYjd0NVFHUGJIWms3OWZMbHpuWU9RTmFaWWJCTGhZaGpMc0kybmx1SGx2YmhReHZuNG5qMkFsZEhOd0JpRFVRPT0iLAogICJTaWduaW5nQ2VydFVSTCIgOiAiaHR0cHM6Ly9zbnMuYXAtc291dGhlYXN0LTIuYW1hem9uYXdzLmNvbS9TaW1wbGVOb3RpZmljYXRpb25TZXJ2aWNlLTAxMGE1MDdjMTgzMzYzNmNkOTRiZGI5OGJkOTMwODNhLnBlbSIKfQ==”
}
]

I got a solution:

JSON.parse(Base64.decode($content))

If there is any better way, please let me know. Thanks.

1 Like

Hi @deepak.shaw

Another way is by using the Document to Binary and Binary to Document snaps. But, my opinion is that using the Base64 encode/decode functions is better approach.

Regards,
Spiro Taleski

Thanks for your advice :grinning:

Hi,
I’m getting Error:
[
{
“failure”: “byte type does not have a method named: content, found in: $payload.content. Perhaps you meant: concat”,
“value”: “Please check expression syntax and data types.”,
“reason”: “Please check expression syntax and data types.”,
“sub-expression”: {
“0: $payload”: [
{
“_snaptype_binary_base64”: “ewogICJUeXBlIiA6ICJOb3RpZmljYXRpb24iLAogICJNZXNzYWdlSWQiIDogIjkxOTI2ZWEyLWE3ODgtNWIxZC1hNTNkLTM3Yzk4MzM0NTliZiIsCiAgIlRvcGljQXJuIiA6ICJhcm46YXdzOnNuczphcC1zb3V0aG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RRGx3a0lCeG1WN0JEdzk5TDN4QWx4THFEY0pLMkVIQkFYRFR4empPTCt1Mk5KNHdvN0ZEK2YvR21xZ1lXbzNDZ09mL1V1RmlIcStwdWozRGhuSi91d3dGQnlmUFJLdlNpemFiS0R1SERiNHNsUlFGV1NrYjcrK0gyVkpJOGZiczdBPT0iLAogICJTaWduaW5nQ2VydFVSTCIgOiAiaHR0cHM6Ly9zbnMuYXAtc291dGhlYXN0LTIuYW1hem9uYXdzLmNvbS9TaW1wbGVOb3RpZmljYXRpb25TZXJ2aWNlLTAxMGE1MDdjMTgzMzYzNmNkOTRiZGI5OGJkOTMwODNhLnBlbSIsCiAgIlVuc3Vic2NyaWJlVVJMIiA6ICJodHRwczovL3Nucy5hcC1zb3V0aGVhc3QtMi5hbWF6b25hd3MuY29tLz9BY3Rpb249VW5zdWJzY3JpYmUmU3Vic2NyaXB0aW9uQXJuPWFybjphd3M6c25zOmFwLXNvdXRoZWFzdC0yOjEwODY1MzYwNzQ1Nzpka3NxdWFyZXVwOjVlZTkwMTcxLTUyMmUtNDNjNi1iZDNkLTQ2YmI2NjAxNjJmMCIKfQ==”
}
]
}
},
{
“failure”: “byte type does not have a method named: content, found in: $payload.content. Perhaps you meant: concat”,

Can you please suggest, what is going wrong here
I’m using Base64.decode($payload.content)

Hi @deepak.shaw

Please ensure that the path you are referring ($payload.content) exist in the input of the Snap where you have the Base64.decode function.

Try to use validation of the pipelines, so you will be able to check/preview the output of every Snap.

Regards,
Spiro Taleski

Thanks Spiro,
I’m getting below error:
Failure: Unable to decode base64 value, Reason: Bad Base64 input character decimal 123 in array position 0, Resolution: Make sure the argument is valid base64

Can you please suggest a fix?

@deepak.shaw

What did you try to put as an argument to the base64.decode function?

You should pass base64 encoded value(string) to the function.

Regards,
Spiro Taleski