You need to sign in to do that
Don't have an account?
dai tran 6
How can call google vision api from apex?
I upload a image and use google vision api ocr it:
Result:
Thank you.
public blob file { get; set; } public void uploadImage() { String b64String = EncodingUtil.base64Encode(file); Http http = new Http(); HttpRequest request = new HttpRequest(); request.setMethod('POST'); request.setHeader('Content-Length', '2000'); request.setHeader('Content-Type', 'application/json'); request.setEndpoint('https://vision.googleapis.com/v1/images:annotate?key=AIzaSyDY2VbfNW9rIXOJs9O....'); request.setBody(b64String); HttpResponse response = http.send(request); imagetext= response.getBody(); System.debug(imagetext); }
Result:
00:01:19.61 (1062397547)|USER_DEBUG|[82]|DEBUG|{ "error": { "code": 400, "message": "Invalid JSON payload received. Expected a value.\n/9j/4AAQSkZJRgABAQAA\n^", "status": "INVALID_ARGUMENT" } }How can call google vision api from apex?
Thank you.
Check this documentation.
https://cloud.google.com/vision/docs/detecting-properties#vision-image-property-detection-protocol
http://prntscr.com/kg3iuo