-
Notifications
You must be signed in to change notification settings - Fork 184
Open
Description
Hello! I'm trying to post an image.
Unfortunately, the process doesn't work.
The current routine is as follows.
The problem is, the following exception is thrown: E2010 Incompatible types: 'string' and 'TObject'
Shouldn't the post method receive such a parameter?
...
TRequestFoto = class(TMultiPartFormData)
vCaminhoFoto : TMultiPartFormAttachment;
end;
...
function TuMercadoLivre.ValidaFoto(vCaminho, vToken : String): TJSONObject;
var
vResponse : String;
vRestClient : TRestClient;
vRequestFoto : TRequestFoto;
begin
vRequestFoto := TRequestFoto.Create;
vRestClient := TRestClient.Create(Nil);
Try
Try
vRestClient.ConnectionType := hctWinHttp;
vRequestFoto.vCaminhoFoto := TMultiPartFormAttachment.Create('C:\SysFire\MercadoLivreFoto\000000000060_1.jpeg', 'multipart/form-data', '000000000060_1.jpeg');
vResponse := vRestClient.
Resource('https://api.mercadolibre.com/pictures/items/upload').
Header('Authorization', 'Bearer ' + vToken).
ContentType('multipart/form-data').
Post(vRequestFoto);
Result := TJSONObject(TJSONObject.ParseJSONValue(TEncoding.UTF8.GetBytes(vResponse), 0));
Except
On E : Exception Do
Raise Exception.Create(E.Message);
End;
Finally
vRestClient.Free;
vRequestFoto.Free;
End;
end;
Metadata
Metadata
Assignees
Labels
No labels