0

I have to set the Authorization header and the body part of a RestRequest in Delphi.

My body part looks like this, it is a JSON:

{
  "Data": {
    "Permissions": [
      "ReadAccountsDetail",
      "ReadBalances",
      "ReadStatementsDetail",
      "ReadTransactionsDetail",
      "ReadTransactionsCredits",
      "ReadTransactionsDebits"
    ],
    "ExpirationDateTime": "2030-08-27T18:08:14.922Z",
    "TransactionFromDateTime": "2012-08-27T18:08:14.922Z",
    "TransactionToDateTime": "2022-08-27T18:08:14.922Z"
  },
  "Risk": {}
}

It works fine in SoapUI, I tested it. Now I want to make a program in Delphi. How can I add this to the body part of the RestRequest, and how can I add the Authentication header to the request?

My token for Authentication is a bit long, and the compiler does not accept it as a literal, is there a workaround for that?

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
  • 1
    "My token for authentication is a bit long and it does not accept it as a literal" Are you talking about string literals, which can only be 255 characters? If so, you can always combine two or more string literals using the `+` operator. – Andreas Rejbrand Oct 16 '20 at 11:45
  • Yes it is a string literal – juniordevjim Oct 16 '20 at 13:22
  • @juniordevjim Have you read [Embarcadero's documentation](http://docwiki.embarcadero.com/RADStudio/en/REST_Client_Library) on how to use the REST components? Also see [how can delphi 'string' literals be more than 255?](https://stackoverflow.com/questions/8767899/) – Remy Lebeau Oct 16 '20 at 17:28
  • @juniordevjim Why would you put your token into a string literal anyway? This is something that’s not code and is subject to change. Just create a config file in which you add an encrypted version of the token and read/decrypt that in your application. – R. Hoek Oct 17 '20 at 13:31

0 Answers0