RTC Forums

Subscription => Support => Topic started by: mkurnia on January 02, 2016, 06:14:34 AM



Title: API with access key and autorization
Post by: mkurnia on January 02, 2016, 06:14:34 AM
hi danijel,

in CURL i use this request to server, how can i use rtchttpclient:

curl -H "X-API-AccessKey: NDc4NTE1MTY1"
     -H "X-API-Timestamp: 2015-06-23T02:51:26+07:00"\n
     -H "Authorization: NDBkYWEwNmRiNTdmYTZiN2I1NzQ1YzAxYTM0M2RjZTYzOTRhZGFkYjE5YjdkMzM3MTgyYTZkYmRmNmM3MzNmNg=="\n
     -v https://api-sandbox.paymentgateway.id/v1/

thanks you.



Title: Re: API with access key and autorization
Post by: D.Tkalcec (RTC) on January 02, 2016, 11:32:18 AM
Please, check Quick Start Client Lesson 1 (http://www.realthinclient.com/sdkarchive/indexd703.html) to learn the basics about TRtcHttpClient and TRtcDataRequest component usage.

Server Address, Port and protocol (HTTP or HTTPS) have to be specified in the TRtcHttpClient component, like this:

RtcHttpClient1.ServerAddr:='api-sandbox.paymentgateway.id'; // Server address
RtcHttpClient1.ServerPort:='443'; // Server Port (443 is standard for HTTPS)
RtcHttpClient1.useSSL:=True; // use SSL property works only on Windows. For other platforms, use 3rd-party encryption components for SSL

HTTP "Method" and "File Name" can be specified on the TRtcDataRequest component using the Request property, like this:

RtcDataRequest1.Request.Method:='GET';
RtcDataRequest1.Request.FileName:='/v1/';

HTTP Header values can be specified on the TRtcDataRequest component using the Request[] property, like this:

RtcDataRequest1.Request['X-API-AccessKey']:='NDc4NTE1MTY1';
RtcDataRequest1.Request['X-API-Timestamp']:='2015-06-23T02:51:26+07:00';
RtcDataRequest1.Request['Authorization']:='NDBkYWEwNmRiNTdmYTZiN2I1NzQ1YzAxYTM0M2RjZTYzOTRhZGFkYjE5YjdkMzM3MTgyYTZkYmRmNmM3MzNmNg==';

For more examples on using TRtcHttpClient and TRtcDataRequest components to post HTTP(S) requests, check the "FileClient" demo in the "Demos" folder and "ClientFormPost" and "ClientUpload" examples in the "QuickStart" folder.

Best Regards,
Danijel Tkalcec