1

I am trying to create a Logic App that is triggered by an HttpRequest that contains as payload a JSON request. Inside of this JSON, one field contains the file:

{
"EntityId": "45643",
"SharedGuid": "00000000-0000-0000-0000-000000000000",
"Document": {
    "DocumentName": "MyFileName.pdf",
    "File": "JVBERi0xLjMKJfv8/f4KMS.....lJUVPRg=="
}}

This "file" content is being generated by the customer application by using the following C# function: File.ReadAllBytes("local path here").

I managed to upload the byte array to blob storage. But the file is not valid once it is uploaded in the Blob Storage.

I tried different file contents for the file in the JSON schema definition as: string, binary, application/octet-stream.

This is how my Logic App looks now

Any help will be appreciated.

1 Answer 1

1

Did you do the operation to convert the byte to Base64String in your httprequest code, just like the code below:

byte[] b = File.ReadAllBytes(@"filepath");
string s = Convert.ToBase64String(b);

According to the file content you provided, it seems you have convert it to base64string as above, so I provide the solution below:

For this requirement, you can just parse the response data as string(do not need to use "binary" in schema) in your "Parse JSON" action and then use base64ToBinary() method in the "Create blob" action, please refer to the screenshot shown as below:

enter image description here The expression in "Blob content" is:

base64ToBinary(body('Parse_JSON')?['Document']?['File'])

Hope it helps~

If still have any problem, please feel free to let me know.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you Hury Shen !!! this function solved the issue base64ToBinary.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.