# Base64Decode Question

**URL:** <https://the.fmsoup.org/t/base64decode-question/2218>\
**Category:** Questions\
**Tags:** community\
**Created:** [June 11, 2021, 5:03pm UTC](https://the.fmsoup.org/t/base64decode-question/2218 "2021-06-11T17:03:19Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![OliverBarrett](https://avatars.discourse-cdn.com/v4/letter/o/f19dbf/32.png) [@OliverBarrett](https://the.fmsoup.org/u/OliverBarrett)\
**Post date:** [June 11, 2021, 5:03pm UTC](https://the.fmsoup.org/t/base64decode-question/2218/1 "2021-06-11T17:03:19Z")

</div>

I am calling a Python Flask REST service which returns a Base64Encoded file result.

In FileMaker, I am first writing that Base64 data to a text field and then doing a Base64Decode("text field; path\_to\_file).

Since Base64Decode doesn't seem to work on a variable like $base64Encoded that the INSERT FROM URL creates as its target, I created this extra step. Also INSERT FROM URL, if I used a field instead of a variable, doesn't let me use a function on the Target field result.

So, three script lines which isn't too bad.

I wanted to ask though if I missed something about how Base64Decode works. Since it wants a "field" and not a variable, I added the extra step to the script.

Thanks for any suggestions for improvement.

---

<div class="post-metadata">

**Author:** ![steve\_ssh](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/steve_ssh/32/160_2.png) [@steve\_ssh](https://the.fmsoup.org/u/steve_ssh)\
**Post date:** [June 11, 2021, 7:11pm UTC](https://the.fmsoup.org/t/base64decode-question/2218/2 "2021-06-11T19:11:39Z")

</div>

Hi Oliver,

I am somewhat surprised to hear that Base64Decode is not working directly on variable argument if that variable does indeed contain just a Base64 text representation of some data. Never have I had such an experience, nor would I have expected it.

Similarly, I am surprised to hear that the function is not allowed to be called on a text field.

It is entirely possible that you have simply run into something that I have never seen, but for the record, and in case it helps, I will mention that I find it odd. I wonder if there is some nuance about the data being returned which needs to be discovered?

Kind regards,

-Steve

---

<div class="post-metadata">

**Author:** ![OliverBarrett](https://avatars.discourse-cdn.com/v4/letter/o/f19dbf/32.png) [@OliverBarrett](https://the.fmsoup.org/u/OliverBarrett)\
**Post date:** [June 11, 2021, 7:25pm UTC](https://the.fmsoup.org/t/base64decode-question/2218/3 "2021-06-11T19:25:21Z")

</div>

[https://help.claris.com/en/pro-help/content/base64decode.html?Highlight=base64decode](https://help.claris.com/en/pro-help/content/base64decode.html?Highlight=base64decode)

---

<div class="post-metadata">

**Author:** ![planteg](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/planteg/32/627_2.png) [@planteg](https://the.fmsoup.org/u/planteg)\
**Post date:** [June 11, 2021, 9:59pm UTC](https://the.fmsoup.org/t/base64decode-question/2218/4 "2021-06-11T21:59:30Z")

</div>

This page in FileMaker Help is not clear as spring water. Base64Decode should take its first argument anything that is a text. Don't forget that what will be decoded is binary, hard to check in the DataViewer.

> Since Base64Decode **doesn't seem to work** on a variable like $base64Encoded that the INSERT FROM URL creates as its target, I created this extra step. Also INSERT FROM URL, if I used a field instead of a variable, doesn't let me use a function on the Target field result.

Can you develop on this ?

Three years ago I had a hard time decoding some base64 encoded data retrieved in Xojo from FileMaker. Doing tests I discovered that encoding on Windows and MacOS did not provided the same result, the reason being the delimiter added at every 76 chars - data is split every 76 characters, but the end-of-line sequence depends on the OS.

This [Base64 Encode and Decode - Online](https://www.base64encode.org/) may help you diagnose what's going on.

---

<div class="post-metadata">

**Author:** ![OliverBarrett](https://avatars.discourse-cdn.com/v4/letter/o/f19dbf/32.png) [@OliverBarrett](https://the.fmsoup.org/u/OliverBarrett)\
**Post date:** [June 12, 2021, 10:53am UTC](https://the.fmsoup.org/t/base64decode-question/2218/5 "2021-06-12T10:53:06Z")

</div>

I tried using the $ variable, but the Base64Decode function said it couldn't find the field. If you could show me how you use the Base64Decode with a variable directly, say a screenshot or FMP sample, that would be helpful.  
Thanks @planteg!

---

<div class="post-metadata">

**Author:** ![steve\_ssh](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/steve_ssh/32/160_2.png) [@steve\_ssh](https://the.fmsoup.org/u/steve_ssh)\
**Post date:** [June 12, 2021, 3:52pm UTC](https://the.fmsoup.org/t/base64decode-question/2218/6 "2021-06-12T15:52:30Z")

</div>

Hello Oliver,

Attached should be a very simple example of using Base64Decode, where its supplied base64 data is held within a variable.

Hope this helps!

-Steve

[Base64.fmp12.zip](https://the.fmsoup.org/uploads/short-url/zjOpsIFd7UDA2tynzgrUxb12oFf.zip) (103.1 KB)

---

<div class="post-metadata">

**Author:** ![OliverBarrett](https://avatars.discourse-cdn.com/v4/letter/o/f19dbf/32.png) [@OliverBarrett](https://the.fmsoup.org/u/OliverBarrett)\
**Post date:** [June 12, 2021, 4:56pm UTC](https://the.fmsoup.org/t/base64decode-question/2218/7 "2021-06-12T16:56:05Z")

</div>

Now that's just strange.

It now works for me also, but when I tried it last time, I got some "could not find field" type error. Maybe a typo (user error....), don't know.

Thanks, @steve_ssh!

Excellent.
