1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
|
procedure TFrmMain.TlbTestClick(Sender: TObject);
var
Client: TFPHttpClient;
ApiCreate : String;
begin
ApiCreate := 'https://gelis.od2.vtiger.com/restapi/v1/vtiger/default/create?elementType=Calendar?element=';
Client := TFPHttpClient.Create(nil);
Client.AddHeader('User-Agent','Mozilla/5.0 (compatible; fpweb)');
Client.AddHeader('Content-Type','application/json; charset=UTF-8');
Client.AddHeader('Accept', 'application/json');
Client.AllowRedirect := true;
Client.UserName:='XXXXXXXX';
Client.Password:='XXXXXX';
//Dans le TMemo (MemRes) j'ai les données JSON :
//{"subject": "Test Ecriture API","assigned_user_id": "19x6",
//"date_start": "2021-05-22","time_end": "","time_start": "07:00:00",
//"due_date": "2021-05-22","recurringtype": "","parent_id": "5x23628","contact_id": "",
//"taskstatus": "Completed","eventstatus": "","taskpriority": "High",
//"sendnotification": "0","activitytype": "Task","duration_hours": "2","visibility": "Private",
//"duration_minutes": "0","location": "","notime": "0","created_user_id": "19x6",
//"source": "CRM","starred": "0","tags": "","record_currency_id": "","record_conversion_rate": "",
//"reminder_time": "","description": "","isclosed": "1","record_currency_symbol": null}
try
try
client.Post(APICREATE+MemRes.Lines.Text);
showmessage('Response Code is ' + inttostr(Client.ResponseStatusCode) + ' - ' + client.ResponseStatusText); // better be 200
except on E:Exception do
showmessage('Something bad happened : ' + E.Message);
end;
finally
Client.RequestBody.Free;
Client.Free;
end; |
Partager