web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Custom Connector #Clar...
Power Apps
Unanswered

Custom Connector #Clarifai_API

(0) ShareShare
ReportReport
Posted on by 66

Hi,

 

I am unable to utilize Clarifai_API for in-built food detection model.

I followed the tutorial mentioned at https://docs.clarifai.com/ & https://www.clarifai.com/models/ai-food-recognition but the operations that I need to perform are not getting through.

Basically, I require my canvas app to pass an image to the API and in return the API provides ingredients list.

I used API key for security:

smehro_0-1629121751852.png

General definition as this

smehro_1-1629121791074.png

Request as

smehro_2-1629121820680.png

Header as (from https://docs.clarifai.com/clarifai-basics/authentication/authorize)

 

curl -X POST \
 -H 'Authorization: Key YOUR_API_KEY' \
 -H "Content-Type: application/json" \
 -d '

 

 The results shows custom connector is created but I simply can't test it.

CC: @v-xiaochen-msft , @cchannon 

Sid

Categories:
I have the same question (0)
  • cchannon Profile Picture
    4,702 Moderator on at

    There's a few things here.

     

    1. Your url is wrong. I looked at the clarifyai documentation for a few minutes and quickly found this page which details how to call their predict endpoint for images. What you'll see there is that the url for the requests follows the format: 

    https://api.clarifai.com/v2/models/{THE_MODEL_ID}/outputs

     2. You haven't defined any body or qs params as far as I can tell. At a minimum, you need to build a JSON body to actually send your image to the api. From the quick glance I took at the documentation, it looks like that body is formed something like this:

    {
     "data": {
     "image": {
     "base64": "'"$(base64 /path/to/image.jpg)"'"
     }
     }
    }

     3. Custom Connectors don't know how to read curl commands. You need to build the header in JSON for the swagger to understand it.

  • Verified answer
    v-xiaochen-msft Profile Picture
    on at

    Hi @smehro ,

     

    I agreed with @cchannon .

    I did a sample for you.

    vxiaochenmsft_0-1629250817486.png

    vxiaochenmsft_1-1629250840313.png

    vxiaochenmsft_2-1629250852673.png

     

    Add a post request .

    vxiaochenmsft_3-1629250924853.png

    URL:https://api.clarifai.com/v2/models/bd367be194cf45149e75f01d59f77ba7/versions/dfebc169854e429086aceb8368662641/outputs

     

    Header:Authorization Key {your key}

     

    Body:

    {
     "inputs": [
     {
     "data": {
     "image": {
     "url": "https://samples.clarifai.com/metro-north.jpg",
     "allow_duplicate_url": true
     }
     }
     }
     ]
    }

     

    Add a policy

    vxiaochenmsft_4-1629251022411.png

    @headers('Access-Token')

     

    Save and test it.

    vxiaochenmsft_5-1629251094186.png

    vxiaochenmsft_6-1629251131204.png

     

    In addition, I did not add response in my example, please don't forget to add it.

     

    Best Regards,
    Wearsky
    If my post helps, then please consider Accept it as the solution to help others. Thanks.

     

     

     

  • smehro Profile Picture
    66 on at

    Thanks Wearsky!

    I performed the steps you mentioned. However, I am getting an error for header: Authorization.

    The error is: 'Authorization' header is not allowed. Use 'API Key' authentication type in the Security tab to set this header.

    smehro_0-1629275389418.png

    smehro_1-1629277137760.png

    I have set authentication type to 'NO Authentication' in the security tab as your screenshot.

  • v-xiaochen-msft Profile Picture
    on at

    Hi @smehro ,

     

    Rename this param. (Access-Token)

    vxiaochenmsft_1-1629277339991.png

     

    vxiaochenmsft_0-1629277281613.png

     

    Best Regard,

    Wearsky

  • smehro Profile Picture
    66 on at

    Hi Wearsky,

    It works! Thanks. 😊

    One last thing: I tried to use a similar custom connector with Onselect of a button as:

     

    Collect(spoonresponses,Spoonacular.acularimage({apiKey:"xxxxxxxx",imageUrl:"https://cdn.pixabay.com/photo/2019/10/12/15/39/falafel-4544137_960_720.jpg",'Content-Type':"application/json"}));
    
    Set(spoondataanswer,spoondata.Run(JSON(spoonresponses,JSONFormat.IndentFour))

     

     I get error: "Invalid type. Expected Object but got Array." in Power Flow.

    smehro_0-1629278717213.pngsmehro_1-1629278743348.png

    Basically, this seems to be an issue with the collector as when there are more than 1 item it sends an array instead of object. The issue is now how to parse a JSON array!

  • smehro Profile Picture
    66 on at

    I was able to rectify this by changing schema to an array.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 793 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 333 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard