Jump to content
Sign in to follow this  
Alex Texera

Call Rest Api from fmx application

Recommended Posts

I have web service with two parameter  (P_NAME, P_BLOB), in database name is varchar type, blob is blob type.

 

When call web service and send data to database name write to database but blob is null. 

 

Any solution?

 

Is it possible use restRequest1,AddBody(..........      how in this situation put parameter?

 

var
   AStream: TFileStream;
begin
    try
        AStream := TFileStream.Create('/storage/emulated/0/DCIM/Camera/IMG_20210410_163743.jpg', fmOpenRead);
        restRequest1.Params.AddItem('P_NAME','img_name', TRESTRequestParameterKind.pkGETorPOST, [],ctNone);
        restRequest1.Params.AddItem('P_BLOB',AStream , TRESTRequestParameterKind.pkREQUESTBODY, [poDoNotEncode], ctIMAGE_JPEG);
        restRequest1.Execute;
        AStream.Free;
     except on E: Exception do
        begin
          ShowMessage(e.Message);
        end;
     end;
end;

 

 

Also I'm try with AddPair but I don't know how assign AStream

 

var
   ABytes: TBytes;
   AStream: TFileStream;

  jsResponse: TJSONValue;
  jsRequest: TJSONObject;
begin
    try
        AStream := TFileStream.Create('/storage/emulated/0/DCIM/Camera/IMG_20210410_163743.jpg', fmOpenRead);
        jsRequest := TJSONObject.Create();

        jsRequest.AddPair('P_NAME', 'Name');
        //jsRequest.AddPair   HOW PUT AStream  to AddPair
        DM.requestZNRInsert.AddBody(jsRequest);
        jsRequest.Free();


****************

 

 

If someone have experience with send blob from fmx app to database via rest api please stay answer.

Edited by Alex Texera

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×