Jump to content
uniGUI Discussion Forums
jasaad

call a web service

Recommended Posts

I used to call a web service like this...

    IdHTTP1 := TIdHTTP.Create(nil);
    IdHTTP1.Request.ContentType := 'application/x-www-form-urlencoded';

    MPData := TIdMultiPartFormDataStream.Create;
    MPData.AddFile('file', Image_File_path, 'image/jpg');
    MPData.AddFormField('apikey', 'xxxxxxxxxxx');
    MPData.AddFormField('language', 'eng');
    MPData.AddFormField('isOverlayRequired', 'False');

    sResponse := IdHTTP1.Post('https://api.ocr.space/parse/image', MPData);

    JsonObject := TJSONObject.Create;
    JsonValue := JsonObject.ParseJSONValue(sResponse);
    JsonValue:=(JsonValue as TJSONObject).Get('ParsedResults').JSONValue;

    if (JsonValue is TJSONArray) then
      sValue := ((JsonValue as TJSONArray).Items[0] as TJSonObject).Get('ParsedText').JSONValue.Value;

    UniMemo1.Lines.Add(sValue);

 

how to do the same using UNIGUI application?

Share this post


Link to post
Share on other sites

Or you can use the TRESTClient, TRESTRequest and TRESTResponse components....depending on your Delphi version.

  • Like 1

Share this post


Link to post
Share on other sites

×