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 / Problem with ComputerV...
Power Apps
Unanswered

Problem with ComputerVisionAPI (Microsoft Cognitive Services) - "InvalidImageUrl"

(0) ShareShare
ReportReport
Posted on by

I'm trying to send an image to ComputerVisionAPI (Microsoft Cognitive Services) with a PowerApp but I always get an error.

I have tried with Camera image and a static image URL but both fail in the same manner.

 

I have a button with OnSelect:

 

ClearCollect(tagCollect, ComputerVisionAPI.TagImage("Image URL", "https://images.pexels.com/photos/36764/marguerite-daisy-beautiful-beauty.jpg").tags.name)

 

or

 

ClearCollect(tagCollect, ComputerVisionAPI.TagImage("Image Content", Camera1.Photo).tags.name)

 

This gives error "Invalid number of arguments".


So I remove the first argument and leave only the URL:

 

ClearCollect(tagCollect, ComputerVisionAPI.TagImage("https://images.pexels.com/photos/36764/marguerite-daisy-beautiful-beauty.jpg").tags.name)

 

or

 

ClearCollect(tagCollect, ComputerVisionAPI.TagImage(Camera1.Photo).tags.name)

 

Now the syntax seems right (no warnings), but when I press the button I get error "The service returned an error: ComputerVisionAPI!TagImage:{"code":"InvalidImageUrl","requestId":02d3d8ea-9521-4f0f-abe1-7d3dcf1bb88a","message":"Can't fetch the image."}

 

If I try the same image url on test console (https://westus.dev.cognitive.microsoft.com/docs/services/56f91f2d778daf23d8ec6739/operations/56f91f2e778daf14a499e1ff), it works.

 

The documentation (not sure if this is official or not http://www.carlosag.net/PowerApps/Connectors/Computer-Vision-API#_Toc1FFCAB37_DescribeImageParameterImage) says that ComputerVisionAPI.TagImage should have two parameters, but it seems to accept only one. So instead of "image url", "[url]" I put just [url]. But it doesn't seem to work. What could be the problem? Has anyone else gotten this to work? 

Categories:
I have the same question (0)
  • v-monli-msft Profile Picture
    on at

    Hi @Anonymous,

     

    I will try to escalate your issue to the pg and will update here once I got further information.

     

    Regards,

    Mona

  • Pranav1824 Profile Picture
    10 on at

    Hi,

     

    The formula is giving me a new error as described below:

     

    { "statusCode": 401, "message": "Access denied due to invalid subscription key. Make sure to provide a valid key for an active subscription." }

    while i am trying to read the business card with the camera.

    the subscription key seems to be correct as it's working correct with the console application.

     

    Any solution?

     

    Best Regards

    Pranav 

  • Pranav1824 Profile Picture
    10 on at

    Hi,

     

    Resolved the issue for invalid key, we have to provide the country region information also.

    Now facing the error as mentioned below:

     

    "InvalidImageUrl","requestId":"some requestId","message":"Can't fetch the image".

     

    Best Regards

    Pranav Gupta

  • rjpower Profile Picture
    6 on at

    Hi @Anonymous, @Pranav1824 @v-monli-msft,

     

    I am also facing the issue. Did you find any solution? I would really appreciate any help you provided. 

     

    Thanks!

     

  • tzavertnik Profile Picture
    31 on at

    Any insight on this. I am able to connect to the ComputerVisionAPI but I am receiving the following message from the service:

     

    The service returned an error: ComputerVisionAPI!OCRText: The server returned an HTTP error with code 0.

     

    Below is the function that I am using: 

     

    ComputerVisionAPI.OCRText(Camera1.Photo,{language: "en", detectOrientation: true})

     

    Azure is registering the traffic. Just not getting a value back.

     

    Any help or direction is appreciated. Thanks.

  • steeleyj Profile Picture
    4 on at

    I am also receiving the "InvalidImageUrl" error when passing a url of an image to be processed by the Computer Vision Powerapp connector. I used the action on select for a button:

     

    ClearCollect(results, ComputerVisionAPI.OCRText("Image URL", <URL to Image>))

    As a work around I ended up having to create an Azure Function in Python to accept an HTTP Request and Call ComputerVisionAPI directly then create a JSON response. Then I created a custom connector for the new Azure Function.  Then I call the above with the new custom connector only passing the url.

     

    AZURE PYTHON FUNCTION

     

    #Python Azure Function to Call ComputerVisionAPI
    #Receives url as json object and then calls CompVis then returns List Object in JSON
    
    import os
    import json
    import httplib, urllib2, base64
    
    
    postreqdata = json.loads(open(os.environ['req']).read())
    
    url = postreqdata['url']
    
    req = urllib2.Request('https://westus.api.cognitive.microsoft.com/vision/v1.0/ocr')
    req.add_header('Content-Type','application/json')
    req.add_header('Ocp-Apim-Subscription-Key', '<KEY>')
    
    res = urllib2.urlopen(req,json.dumps({'url': url}))
    data = res.read()
    
    parsed = json.loads(data)
    
    textList = []
    
    for regions in parsed['regions']:
     for lines in regions['lines']:
     for words in lines['words']:
     textList.append(words.get('text'))
    
    
    response = open(os.environ['res'], 'w')
    response.write(json.dumps(textList, sort_keys=True, indent=2))
    response.close()

     

    SWAGGER FOR CUSTOM CONNECTOR

    {
     "swagger": "2.0",
     "info": {
     "description": "CompVISAPI",
     "version": "CompVISAPI",
     "title": "CompVISAPI"
     },
     "host": "<name_of_azure_functions>.azurewebsites.net",
     "basePath": "/",
     "schemes": [
     "https"
     ],
     "consumes": [],
     "produces": [],
     "paths": {
     "/api/<name_of_function>": {
     "post": {
     "summary": "azure function to call Computer Vision API for powerapps",
     "operationId": "OCRText",
     "produces": [
     "application/json; charset=utf-8"
     ],
     "responses": {
     "200": {
     "description": "OK",
     "schema": {
     "type": "array",
     "items": {
     "type": "string"
     }
     },
     "headers": {
     "Cache-Control": {
     "description": "Cache-Control",
     "type": "string"
     },
     "Content-Encoding": {
     "description": "Content-Encoding",
     "type": "string"
     },
     "Content-Length": {
     "description": "Content-Length",
     "type": "integer"
     },
     "Content-Type": {
     "description": "Content-Type",
     "type": "string"
     },
     "Date": {
     "description": "Date",
     "type": "string"
     },
     "Expires": {
     "description": "Expires",
     "type": "integer"
     },
     "Pragma": {
     "description": "Pragma",
     "type": "string"
     },
     "Server": {
     "description": "Server",
     "type": "string"
     },
     "Vary": {
     "description": "Vary",
     "type": "string"
     },
     "X-AspNet-Version": {
     "description": "X-AspNet-Version",
     "type": "string"
     },
     "X-Powered-By": {
     "description": "X-Powered-By",
     "type": "string"
     }
     }
     }
     },
     "parameters": [
     {
     "name": "Content-Type",
     "in": "header",
     "description": "",
     "required": false,
     "type": "string"
     },
     {
     "name": "code",
     "in": "query",
     "type": "string",
     "description": "",
     "required": true
     },
     {
     "name": "body",
     "in": "body",
     "schema": {
     "description": "",
     "type": "object",
     "properties": {
     "url": {
     "type": "string",
     "minLength": 1
     }
     },
     "required": [
     "url"
     ]
     },
     "description": "",
     "required": true
     }
     ],
     "description": "jsw azure function"
     }
     }
     },
     "definitions": {},
     "parameters": {},
     "responses": {},
     "securityDefinitions": {},
     "security": [],
     "tags": []
    }

    It would be nice to not have to use this work around.

  • tzavertnik Profile Picture
    31 on at

    The issue that I was encoutering was when I was trying to take a picture from my device/PowerApp and send it directly to ComputerVisionAPI service. Trying to make a business card reader using the Text to OCR and LUIS.

     

    I actually overcame the issue by leveraging what Paul Culmsee (https://www.youtube.com/watch?v=mp-8B1fLrqs) and John Lui (http://johnliu.net/blog/2017/5/taking-a-picture-with-powerapps-and-sending-to-sharepoint-with-just-flow?rq=powerapp) outlined by utilizing a custom flow with "When a HTTP request is received". The Flow would receive the raw image and I would store the file into a SharePoint document library, then grab the file, send it to the OCR to Text, take the text and send it to LUIS and then send the data back to the PowerApp.

     

    It probably isn't the correct way to accomplish this but I was able to make it work. If there is a better way to accomplish this, I am all ears.

  • Community Power Platform Member Profile Picture
    on at

    Hi @Anonymous,

     

    Me too, I have try to use vision api for my apps. Have you find any ideas this topic. I did different code that like your say and other people say. I didn't find any solution. if you have, could you share with me please ? 

    Thank you ,

    Best Regards.

  • Community Power Platform Member Profile Picture
    on at

    Im experiencing this problem too with error "Image URL is Badly formatted" even the same connector is working on Flow

     

    Have anyone tryied with embedded-PowerApps flow to acheive this?

     

     

    Set(resu,ComputerVisionAPI.OCRText("Image Content",{Image:Image2.Image}).text);Label3.Text = resu

     When I try to use it from the cell phone says:

    Error from ComputerVisionAPI.OCRText: null is not an object (evaluating 'e.status')

     

    And I confirm that I'm receiving "Client Error" on the API azure management metrics.

  • Community Power Platform Member Profile Picture
    on at

    Understanding the problem and a lot of reading, the problem is powerapps base64 image-format and all api, endpoints from computervision API, sharepoint, onedrive etc. are expecting binary file format.

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