cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
nmaenpaa
Level: Power Up

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

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/56f91f2...), it works.

 

The documentation (not sure if this is official or not http://www.carlosag.net/PowerApps/Connectors/Computer-Vision-API#_Toc1FFCAB37_DescribeImageParameter...) 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? 

12 REPLIES 12
Community Support Team
Community Support Team

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

Hi @nmaenpaa,

 

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

 

Regards,

Mona

Community Support Team _ Mona Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Pranav1824
Level: Powered On

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

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
Level: Powered On

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

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
Level: Powered On

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

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

 

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

 

Thanks!

 

Highlighted
tzavertnik
Level: Powered On

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

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
Level: Powered On

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

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
Level: Powered On

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

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-f...) 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.

bahardurmus
Level: Powered On

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

Hi @nmaenpaa,

 

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.

diegolin
Level: Powered On

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

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.

Helpful resources

Announcements
firstImage

PowerApps Monthly Community Call!

Join us next Wednesday for our Demo Extravaganza, October 16, 2019 8am PDT.

firstImage

Microsoft Business Applications Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

SecondImage

Power Platform Summit North America

Register by September 5 to save $200

Top Kudoed Authors
Users Online
Currently online: 289 members 3,988 guests
Please welcome our newest community members: