Convert Watson cURL to Mendix Rest call: how to send an image?

0
I'm trying to get the Watson Visual Recognition to work. The first choice would be the Watson Connector module, however this module uses an old version of authentication and doesn't work anymore. Using REST, I can use either a GET based on this cURL which needs an image URL: curl -u "apikey:{apikey}" "https://gateway.watsonplatform.net/visual-recognition/api/v3/detect_faces?url={imageurl}&version=2018-03-19" Or I can use a POST which sends an image: curl -X POST -u "apikey:{apikey}" -F "images_file=@{filename}" "https://gateway.watsonplatform.net/visual-recognition/api/v3/detect_faces?version=2018-03-19"   I'm able to run the REST call with an image URL, however I want to make a picture with a phone and send that picture in. So how do I get a URL of a system.image object? Second option: how do I send the file properly with a REST call? I've tried putting it in as a string, as base 64 encoded string, but nothing seems to work. Any ideas? Thanks!
asked
4 answers
3

While this may be a bit different than using Watson with this, I was successful in POSTing an image using the Mendix REST Module (post JA) from the appstore instead of the native REST call. Listed below is the link to the answer I found to make this work.

https://forum.mendix.com/link/questions/90668

If you create a NPE called Root and associate it to the system.image entity and then set the association name as 'images_file' (or in my case "some_data") this worked for me. Use the REST Module "post" Java Action and set the "Submit as form data" to true it sets that for you. I did not add any other headers (were not needed) other than the Authorization.

 

 

answered
1

Hi Sytze,

This is exactly what we did using plain Mendix 7.15.1.  Using the Watson Services module. 

 

https://modelshare.mendix.com/models/9b466026-4b39-427f-a147-fba377d50b29/post-watson-image-for-recognition.

https://www.dropbox.com/s/olefs374jo8zkqj/SUB_Classify_Image_POST.mpk?dl=0

answered
0

In the Capp REST Service Action, for the Request, you can choose "Binary for the Entire Request". You can select an image there.

See https://docs.mendix.com/refguide/call-rest-action

answered
0

A new test in Postman was succesful: using 'Content-Type: form-data' and adding a key in the body 'images_file' and set a file as value works. But how to set a file as value within Mendix?

answered