I have hacked together some code that may help here. Create a new VCL Forms Application, drop a button and a memo onto the form and use the following code:
const
cArr: TArray<string> = [ //
'object RESTClient1: TRESTClient', //
' BaseURL = ', //
' ''https://api-eu1.XXXXXXXXXXXXXXX/ORD''', //
' Params = <>', //
'end', //
'object RESTRequest1: TRESTRequest', //
' AssignedValues = [rvConnectTimeout, rvReadTimeout]', //
' Client = RESTClient1', //
' Method = rmPOST', //
' Params = <', //
' item', //
' Kind = pkHTTPHEADER', //
' Name = ''x-api-compleat-key''', //
' Value = ''0aXXXXXXXXXXXXXXXXXXXXXX94''', //
' end', //
' item', //
' Kind = pkREQUESTBODY', //
' Name = ''body9BE6CF603159471FB026D7FF6FC3D2DB''', //
' Value = ', //
' ''{"master_id":1,"LayoutID":"d967cc4c-5b2b-4474-8cac-a71f9684ee70"'' +', //
' '',"TransactionStatus":"SAV","Reference":1,"PoNumber":"ORD1","Date'' +', //
' ''Created":"2008-07-08","SupplierName":"TMB","CurrencyCode":"GBP",'' +', //
' ''"SupplierID":"1234","LineItems":[{"master_id":1,"Description":"G'' +', //
' ''obo Original","UnitCost":"100.00","Net":"100.00","Quantity":1,"T'' +', //
' ''ax":0,"Gross":100},{"master_id":1,"Description":"Gobo Copy","Uni'' +', //
' ''tCost":"50.00","Net":"100.00","Quantity":2,"Tax":0,"Gross":100}]'' +', //
' ''}''', //
' ContentType = ctAPPLICATION_JSON', //
' end>', //
' Response = RESTResponse1', //
'end', //
'object RESTResponse1: TRESTResponse', //
'end', //
''];
procedure TForm649.Button1Click(Sender: TObject);
var
binary: TMemoryStream;
cmp: TComponent;
lst: TStringList;
stream: TMemoryStream;
begin
RegisterClasses([TRESTClient, TRESTRequest, TRESTResponse]);
lst := TStringList.Create;
try
lst.Add('object myName: TComponent'); // name doesn't really matter
lst.AddStrings(cArr);
lst.Add('end');
stream := TMemoryStream.Create;
try
lst.SaveToStream(stream);
stream.Position := 0;
binary := TMemoryStream.Create;
try
ObjectTextToBinary(stream, binary);
binary.Position := 0;
binary.ReadComponent(Self); // Self puts the code into the form itself, but any other component will do
finally
binary.Free;
end;
finally
stream.Free;
end;
finally
lst.Free;
end;
cmp := FindComponent('RESTRequest1');
if cmp is TRESTRequest then begin
Memo1.Lines.Add(TRESTRequest(cmp).Params[1].Value);
end;
end;