@@ -69,6 +69,11 @@ The ApiUtilLib Library provide the utility class ApiList to construct request Qu
6969 // phoneNo=%2B1+1234+4567+890&street=Hellowood+Street&state=AP
7070```
7171
72+ ** NOTE**
73+
74+ For ** formData** parameter used for Signature generation, the key value parameters ** do not** need to be URL encoded,
75+ When you use this client library method ** ApiAuthorization.HttpRequest** , it will do the url-encoding during the HTTP call
76+
7277### How to Generate HMAC256 L1 Authorization Header
7378```
7479public static void L1Sample()
@@ -180,6 +185,53 @@ static string GetLocalPath(string relativeFileName)
180185
181186 return localPath;
182187}
188+ ```
189+ #### Sample HTTP POST Call for x-www-form-urlencoded with APEX L1 Security (for reference only)
190+
191+ ```
192+ [Test]
193+ public static void Http_Call_Test()
194+ {
195+ // application realm
196+ string realm = "http://example.api.test/token";
197+
198+ // authorization prefix
199+ string authPrefix = "Apex_l1_eg";
200+
201+ // app id and app secret assign to the application
202+ string appId = "tenant-1X2w7NQPzjO2azDu904XI5AE";
203+ string appSecret = "s0m3s3cr3t";
204+ var formData = new ApiUtilLib.ApiList();
205+
206+ formData.Add("key1", "value1);
207+ formData.Add("key2", "value2");
208+
209+ // api signing gateway name and path
210+ string gatewayName = "https://tenant.e.api.gov.sg";
211+ string apiPath = "api14021live/resource";
212+ string baseUrl = string.Format("{0}/{1}", gatewayName, apiPath);
213+ Console.WriteLine("\n>>>baseUrl :: '{0}'<<<", baseUrl);
214+ Console.WriteLine("\n>>>appId :: '{0}'<<<", appId);
215+ Console.WriteLine("\n>>>appSecret :: '{0}'<<<", appSecret);
216+ // authorization header
217+ var authorizationHeader = ApiAuthorization.Token(realm, authPrefix, HttpMethod.POST, new Uri(baseUrl), appId, appSecret, formData);
218+
219+ Console.WriteLine("\n>>>Authorization Header :: '{0}'<<<", authorizationHeader);
220+
221+ // if the target gateway name is different from signing gateway name
222+ string targetBaseUrl = "https://tenant.api.gov.sg/api14021live/resource";
223+
224+
225+ // this method only for verification only
226+ // expecting result to be 200
227+
228+ var result = ApiAuthorization.HttpRequest(new Uri(targetBaseUrl), authorizationHeader, formData, HttpMethod.POST, ignoreServerCert: true);
229+ Console.WriteLine(result);
230+ Console.ReadLine();
231+
232+ Assert.True(true);
233+ }
234+
183235```
184236
185237## Release
0 commit comments