How to store images returned by REST service

If you have questions or if you want to share your opinion about Aware IM post your message on this forum
Post Reply
karelh
Posts: 86
Joined: Wed Oct 26, 2016 10:20 pm

How to store images returned by REST service

Post by karelh »

Hi all,

Hope someone can assist here...

I am trying to make use of a very basic rest service as described in the documentation below:
https://dashboard.clearbit.com/docs#logo-api

You simply send it a url and it returns a PNG file. (Logo of the associate URL).

In my AIM app I have configured (see below) the response as a image/PNG but when I request the service I get the error "Nonexistent attribute:
LogoDOCTYPE"

I tried it with Postman and it returns the image as expected.
Screenshot 2023-01-21 at 18.17.49.jpg
Screenshot 2023-01-21 at 18.17.49.jpg (175.42 KiB) Viewed 19637 times
Screenshot 2023-01-21 at 18.21.32.png
Screenshot 2023-01-21 at 18.21.32.png (34.21 KiB) Viewed 19637 times
Screenshot 2023-01-21 at 18.18.00.jpg
Screenshot 2023-01-21 at 18.18.00.jpg (124.43 KiB) Viewed 19637 times

Any suggestions?[
karelh
Posts: 86
Joined: Wed Oct 26, 2016 10:20 pm

Re: How to store images returned by REST service

Post by karelh »

See below postman result:
Screenshot 2023-01-21 at 18.27.28.jpg
Screenshot 2023-01-21 at 18.27.28.jpg (54.9 KiB) Viewed 19634 times
BobK
Posts: 544
Joined: Thu Jan 31, 2008 2:14 pm
Location: Cincinnati, Ohio, USA

Re: How to store images returned by REST service

Post by BobK »

karelh,

I am not sure this is possible with AwareIM out of the box.

I expose a web service that allows users to send us a picture, and the data for that picture needs to be in a certain format.
See forum post: https://www.awareim.com/forum/viewtopic.php?f=1&t=11766

I am exposing a web service and you are consuming a web service, but I assume the data for the image you are getting back needs to be in a similar format as what I needed. I doubt the web service you are consuming is returning the data in the AwareIM required format.
Bob
Jaymer
Posts: 2430
Joined: Tue Jan 13, 2015 10:58 am
Location: Tampa, FL
Contact:

Re: How to store images returned by REST service

Post by Jaymer »

So what if you receive the image into a plain text field.
And then did an assignment statement in a rule concatenating the file name and the “hash” in front of that text string into picture field.
I wonder what would happen
Click Here to see a collection of my tips & hacks on this forum. Or search for "JaymerTip" in the search bar at the top.

Jaymer
Aware Programming & Consulting - Tampa FL
Jaymer
Posts: 2430
Joined: Tue Jan 13, 2015 10:58 am
Location: Tampa, FL
Contact:

Re: How to store images returned by REST service

Post by Jaymer »

If you can at least get it into that text field, then you are very close from a very small Java function to set that data into the picture field, in the event that the assignment I spoke of prior, doesn’t work because of syntax.

ThePic = myfunc(filename, base64data)
Click Here to see a collection of my tips & hacks on this forum. Or search for "JaymerTip" in the search bar at the top.

Jaymer
Aware Programming & Consulting - Tampa FL
karelh
Posts: 86
Joined: Wed Oct 26, 2016 10:20 pm

Re: How to store images returned by REST service

Post by karelh »

HI guys,

Thanks for the ideas and response.

Yeah I have tried that but it does not work either. So from the postman response headers I can confirm that the content returned is image/PNG and when I select this as the content type in AIM a have to select a PICTURE type attribute. See below:
Screenshot 2023-01-23 at 20.37.45.jpg
Screenshot 2023-01-23 at 20.37.45.jpg (118.63 KiB) Viewed 19590 times
If I do select a text field, I need to change the content type and if I do I get the below response.
Screenshot 2023-01-23 at 20.39.02.png
Screenshot 2023-01-23 at 20.39.02.png (45.55 KiB) Viewed 19590 times
PointsWell
Posts: 1457
Joined: Tue Jan 24, 2017 5:51 am
Location: 'Stralya

Re: How to store images returned by REST service

Post by PointsWell »

karelh wrote: Mon Jan 23, 2023 6:44 pm So from the postman response headers I can confirm that the content returned is image/PNG and when I select this as the content type in AIM a have to select a PICTURE type attribute.
That error message is suggesting that Customer.LogoBase is not an attribute of type Picture.
karelh
Posts: 86
Joined: Wed Oct 26, 2016 10:20 pm

Re: How to store images returned by REST service

Post by karelh »

Hi PointsWell,

Thanks and that is what I also assumed but if I select the correct content type and picture attribute I still get an error "Nonexistant attribute: LogoDOCTYPE"

I also tried moving that picture attribute to the disk instead of the DB but no luck.
aware_support
Posts: 7523
Joined: Sun Apr 24, 2005 12:36 am
Contact:

Re: How to store images returned by REST service

Post by aware_support »

Could you please send us a BSV for testing and describe how to reproduce the problem in this BSV?
Aware IM Support Team
aware_support
Posts: 7523
Joined: Sun Apr 24, 2005 12:36 am
Contact:

Re: How to store images returned by REST service

Post by aware_support »

Please retest this in build 3125
Aware IM Support Team
karelh
Posts: 86
Joined: Wed Oct 26, 2016 10:20 pm

Re: How to store images returned by REST service

Post by karelh »

HI support,

Do you still need a sample BSV or should we just wait for version 3125?
PointsWell
Posts: 1457
Joined: Tue Jan 24, 2017 5:51 am
Location: 'Stralya

Re: How to store images returned by REST service

Post by PointsWell »

karelh wrote: Thu Feb 09, 2023 6:56 am HI support,

Do you still need a sample BSV or should we just wait for version 3125?
https://www.awareim.com/dokuwiki/doku.p ... g/8.8/3125
aware_support
Posts: 7523
Joined: Sun Apr 24, 2005 12:36 am
Contact:

Re: How to store images returned by REST service

Post by aware_support »

This build is out, so please test the problem in that build.
Aware IM Support Team
karelh
Posts: 86
Joined: Wed Oct 26, 2016 10:20 pm

Re: How to store images returned by REST service

Post by karelh »

Hi support,

I installed the new version but now get the following error when the API is called.


com.bas.basserver.executionengine.ExecutionException: Service provider returned the following error: Internal error. Error writing attribute (conn=25564) You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '[B@1dd8fa37 WHERE ID=8249' at line 1
Screenshot 2023-02-10 at 14.40.45.png
Screenshot 2023-02-10 at 14.40.45.png (37.27 KiB) Viewed 19350 times
aware_support
Posts: 7523
Joined: Sun Apr 24, 2005 12:36 am
Contact:

Re: How to store images returned by REST service

Post by aware_support »

Can you please send us the BSV to test?
Aware IM Support Team
Post Reply