Alloy Appcelerator で Google Vision API v1 を使おうとしていました
リクエスト HTTPClient を作成し、API https://vision.googleapis.com/v1/images:annotate?key=MY_APP_KEYを呼び出します
しかし、私はグーグルから応答テキストを取得しました:
{
error = {
code = 400;
details = (
{
"@type" = "type.googleapis.com/google.rpc.BadRequest";
fieldViolations = ({
description = "Invalid JSON payload received. Unknown name \"request\": Cannot bind query parameter. Field 'request' could not be found in request message.";
});
}
);
message = "Invalid JSON payload received. Unknown name \"request\": Cannot bind query parameter. Field 'request' could not be found in request message.";
status = "INVALID_ARGUMENT";
};
}
そして、AlloyによるHTTPリクエストを使用する私のコードがあります
var requests =
{
"requests":[
{
"image":{
"content": "image_have_encodebase64",
},
"features":[
{
"type":"TEXT_DETECTION",
"maxResults":1
}
]
}
]
};
var xhr = Titanium.Network.createHTTPClient();
xhr.open("POST", 'https://vision.googleapis.com/v1/images:annotate?key=MY_APP_KEY');
xhr.send(JSON.stringify(requests));
ご協力いただきありがとうございます