Donny
Donny

Reputation: 718

Watson visual recognition bad request 400

I have a watson instance that works fine with cURL

curl -X POST -u "apikey:skjfdk" --form "[email protected]" "https://gateway.watsonplatform.net/visual-recognition/api/v3/classify?version=2018-03-19&&classifier_ids=myclassifier"
{
    "images": [
        {
            "classifiers": [
                {
                    "classifier_id": "myclassifier",
                    "name": "myclassifier",
                    "classes": [
                        {
                            "class": "pot",
                            "score": 0.905
                        }
                    ]
                }
            ],
            "image": "newpot.jpg"
        }
    ],
    "images_processed": 1,
    "custom_classes": 4
}

But when I access it via REST CLIENT or simple Javascript ajax form upload it gives this error. What can be the possible reason? I am sure I am not adding any additional headers in the request as the error claims. Attached screenshot of my rest client

{
    "images": [
        {
            "image": "newpot.jpg",
            "error": {
                "code": 400,
                "description": "Invalid Request: vr.Classifier/classify: INVALID_ARGUMENT: Accept-Language header must be a supported 2 letter ISO 639-1 language code or 5 letter ITEF BPC 47 language code. Received 'en-u-rg-uszzzz'"
            }
        }
    ],
    "images_processed": 1
}

Body of the request

Headers

Upvotes: 0

Views: 262

Answers (2)

Matt Hill
Matt Hill

Reputation: 1106

Like Allen wrote, apparently postman was inserting a default language header, but coincidentally we had a bug which misinterpreted that header. A fix was deployed Friday Jan 18. This behavior should not recur.

Upvotes: 1

Allen Dean
Allen Dean

Reputation: 597

That looks like a locale-specific region override of the Accept-Language header. It must be getting sent somehow.

Check the console of Postman; you might see that the accept-language header is being sent. You could also explicitly include the header with a different value (for example, de) to see if you get different behavior.

Upvotes: 1

Related Questions