Skip to main content

Notifications

Community site session details

Community site session details

Session Id : +A402jjzg4Z2OOWxarVcI4
Power Apps - Building Power Apps
Answered

Custom Connector #Clarifai_API

Like (0) ShareShare
ReportReport
Posted on 16 Aug 2021 13:54:18 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

  • smehro Profile Picture
    66 on 19 Aug 2021 at 14:34:16
    Re: Custom Connector #Clarifai_API

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

  • smehro Profile Picture
    66 on 18 Aug 2021 at 09:28:36
    Re: Custom Connector #Clarifai_API

    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!

  • v-xiaochen-msft Profile Picture
    on 18 Aug 2021 at 09:01:48
    Re: Custom Connector #Clarifai_API

    Hi @smehro ,

     

    Rename this param. (Access-Token)

    vxiaochenmsft_1-1629277339991.png

     

    vxiaochenmsft_0-1629277281613.png

     

    Best Regard,

    Wearsky

  • smehro Profile Picture
    66 on 18 Aug 2021 at 08:59:15
    Re: Custom Connector #Clarifai_API

    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.

  • Verified answer
    v-xiaochen-msft Profile Picture
    on 18 Aug 2021 at 01:46:51
    Re: Custom Connector #Clarifai_API

    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.

     

     

     

  • cchannon Profile Picture
    4,702 Super User 2025 Season 1 on 17 Aug 2021 at 12:41:19
    Re: Custom Connector #Clarifai_API

    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.

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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,765 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,091 Most Valuable Professional

Leaderboard