# Problem with cfhttp get image QR code

**URL:** <https://dev.lucee.org/t/problem-with-cfhttp-get-image-qr-code/13861>\
**Category:** support\
**Created:** [May 15, 2024, 7:41am UTC](https://dev.lucee.org/t/problem-with-cfhttp-get-image-qr-code/13861 "2024-05-15T07:41:34Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![interbilk](https://dev.lucee.org/letter_avatar_proxy/v4/letter/i/f0a364/32.png) [@interbilk](https://dev.lucee.org/u/interbilk)\
**Post date:** [May 15, 2024, 7:41am UTC](https://dev.lucee.org/t/problem-with-cfhttp-get-image-qr-code/13861/1 "2024-05-15T07:41:34Z")

</div>

Hi All, i have a problem. I generate external an QR code.  
and get the image and save on my server. in the past I use ColdFusion. all was fine.  
now I switch to Lucee. but if I get the image it don’t run as an QR code. if I want to scan “error”  
if I run the url in cfhttp in the browser I get the image and all is fine.  
does anyone knows what I do wrong?  
Or have anyone another solution to generate a qrcode on the server, instead external?

Here is my code

```auto
<cfhttp
method="Get"
url="https://api.qrserver.com/v1/create-qr-code/?size=350x350&data=BEGIN:VCARD%20%0AVERSION:3.0%20%0AN:Peter; Pan%20%0ATITLE:Manager%20%0ATEL;TYPE=CELL:0221 1224545 %20%0ATEL;TYPE=VOICE,WORK: %20%0ATEL;TYPE=FAX: %20%0AEMAIL;TYPE=WORK:peter@Pan.de%20%0AURL:www.peterpan.de%20%0AADR;TYPE=WORK:;;Ernst-D%C3%nn-Allee 1;Köln;;50554;Germany%20%0AORG:Meister GmbH%20%0AEND:VCARD" charset=„UTF“-8 getAsBinary = "true" >

        <cfimage source="#cfhttp.filecontent#" destination="#temp_vorschau#/pdf/22222_2.png" action="write" overwrite="yes">

```

This image is ok

```auto
[type or paste code here](https://api.qrserver.com/v1/create-qr-code/?size=350x350&data=BEGIN:VCARD%20%0AVERSION:3.0%20%0AN:Peter)

```

_Don’t forget to tell us about your stack!_

**OS** : Ubuntu 18  
**Java Version** : 11.0.22 (Eclipse Adoptium) 64bit  
**Tomcat Version** : 9  
**Lucee Version** : 6.0.1.83

---

<div class="post-metadata">

**Author:** ![interbilk](https://dev.lucee.org/letter_avatar_proxy/v4/letter/i/f0a364/32.png) [@interbilk](https://dev.lucee.org/u/interbilk)\
**Post date:** [May 15, 2024, 9:12am UTC](https://dev.lucee.org/t/problem-with-cfhttp-get-image-qr-code/13861/2 "2024-05-15T09:12:25Z")

</div>

I tasted it again. save the good qr image on another server…  
and get it. ll is ok…  
The error must happen when I transfer the url. Something seems to be going wrong

---

<div class="post-metadata">

**Author:** ![raffaelmeier](https://dev.lucee.org/user_avatar/dev.lucee.org/raffaelmeier/32/2939_2.png) [@raffaelmeier](https://dev.lucee.org/u/raffaelmeier)\
**Post date:** [May 15, 2024, 1:04pm UTC](https://dev.lucee.org/t/problem-with-cfhttp-get-image-qr-code/13861/3 "2024-05-15T13:04:53Z")

</div>

imho the url is not valid with space characters, it should be urlencoded.  
does this work?

```auto
<cfset temp_url = "https://api.qrserver.com/v1/create-qr-code/?size=350x350&data=BEGIN:VCARD%20%0AVERSION:3.0%20%0AN:Peter; Pan%20%0ATITLE:Manager%20%0ATEL;TYPE=CELL:0221 1224545 %20%0ATEL;TYPE=VOICE,WORK: %20%0ATEL;TYPE=FAX: %20%0AEMAIL;TYPE=WORK:peter@Pan.de%20%0AURL:www.peterpan.de%20%0AADR;TYPE=WORK:;;Ernst-D%C3%nn-Allee 1;Köln;;50554;Germany%20%0AORG:Meister GmbH%20%0AEND:VCARD">
<cfset temp_url = URLEncodedFormat(temp_url, "utf-8")>

<cfhttp method="Get" url="#temp_url#" charset="utf-8" getAsBinary = "true" >
<cfimage source="#cfhttp.filecontent#" destination="#temp_vorschau#/pdf/22222_2.png" action="write" overwrite="yes">

```

---

<div class="post-metadata">

**Author:** ![andreas](https://dev.lucee.org/user_avatar/dev.lucee.org/andreas/32/3352_2.png) [@andreas](https://dev.lucee.org/u/andreas)\
**Post date:** [May 17, 2024, 5:10am UTC](https://dev.lucee.org/t/problem-with-cfhttp-get-image-qr-code/13861/4 "2024-05-17T05:10:15Z")

</div>

Just for completeness, there are also alternatives to create QRCodes locally for your reference, here is an example.

> [@Add new font for cfdocument](https://dev.lucee.org/t/add-new-font-for-cfdocument/3174/16):
>
> May be this jars won’t be loaded because of not being OSGI compliant? You can try creating the OSGI Manifest/Metadata (what I’ve never done) or try using Mark Mandels Javaloader, a very valuable tip that I’ve learnt from @Julian_Halliwell1. If this works for you, do the following: Go to [Mark Mandels Github Javaloader Repository](https://github.com/markmandel/JavaLoader) and download the Javaloader (this is the javaloader-folder in his repository) to your webroot: Create a folder in your webroot named lib, and add the jars to the li…

This is also possible with the OSGI compliant library, but I can’t find that post anymore. 😕 I’ll document it as soon as I have some time.

---

<div class="post-metadata">

**Author:** ![kenricashe](https://dev.lucee.org/user_avatar/dev.lucee.org/kenricashe/32/3476_2.png) [@kenricashe](https://dev.lucee.org/u/kenricashe)\
**Post date:** [May 17, 2024, 8:12pm UTC](https://dev.lucee.org/t/problem-with-cfhttp-get-image-qr-code/13861/5 "2024-05-17T20:12:04Z")

</div>

Also if you only need to _display_ QR codes, thus reducing storage space and other server resources, you could use a JavaScript library. There are many available and my choice was [QRCode.js](https://davidshimjs.github.io/qrcodejs/). I’ve been using it for several years and it still works perfectly and is supported by [cdnjs](https://cdnjs.com/libraries/qrcodejs) and [jsDelivr](https://www.jsdelivr.com/package/npm/qrcodejs).

---

<div class="post-metadata">

**Author:** ![andreas](https://dev.lucee.org/user_avatar/dev.lucee.org/andreas/32/3352_2.png) [@andreas](https://dev.lucee.org/u/andreas)\
**Post date:** [May 18, 2024, 8:40am UTC](https://dev.lucee.org/t/problem-with-cfhttp-get-image-qr-code/13861/6 "2024-05-18T08:40:40Z")

</div>

Awesome! Why not saving the data to a variable and keep the QRGenerator working fully on client-side? Excellent! Thanks @kenricashe for sharing!
