Updating the currency rate by API

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sobolevfff
    Member
    • Mar 2020
    • 81

    #16
    Corrected. But I wrote above that I tried different options and they do not work.

    'CurrencyRate'
    'currencyRate'
    'currency'

    There are no errors, but there is no result.

    Comment

    • item
      Active Community Member
      • Mar 2017
      • 1476

      #17
      Hi,
      i think Yuri say this :
      PHP Code:
      
      try {
          $response = $client->request(
              'PUT',
              'CurrencyRate',   <---
              ['EUR' => 1.19]
          );
      } catch (\Exception $e) {
          $errorCode = $e->getCode();
      } 
      
      Last edited by item; 10-22-2020, 08:32 PM.
      If you could give the project a star on GitHub. EspoCrm believe our work truly deserves more recognition. Thanks.​

      Comment

      • sobolevfff
        Member
        • Mar 2020
        • 81

        #18
        <?php
        require_once('EspoApiClient.php');

        $url = 'https://aaaaaaaaaaa.com/crm/';
        $apiKey = '2e5ca0f7***************c60684e9';

        $client = new EspoApiClient($url);
        $client->setApiKey($apiKey);

        try {
        $response = $client->request(
        'PUT',
        'CurrencyRate',
        ['EUR' => 1.7777]
        );
        } catch (\Exception $e) {
        $errorCode = $e->getCode();
        }
        ?>


        Yes. I understood you correctly. I meant that I tried different options.

        Comment

        • sobolevfff
          Member
          • Mar 2020
          • 81

          #19
          Has anyone tested this on their own? Does it even work?

          Comment

          • yuri
            Member
            • Mar 2014
            • 8453

            #20
            The snippet I provided above was tested and it worked.
            If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

            Comment

            • heduardo26
              Junior Member
              • Mar 2021
              • 1

              #21
              I have this code and always return 400, I think is (bad request error)

              <?php

              require_once('EspoApiClient.php');

              $url = 'http://17X.XX.XX.X4/bis/';
              $apiKey = '997e6xxxxxxxxxxxxxxxxxxxx529bf2';

              $client = new EspoApiClient($url);
              $client->setApiKey($apiKey);

              // example creating a new lead
              try {
              $response = $client->request(
              'PUT ',
              'CurrencyRate ',
              ['VES' => 1.19]
              );

              } catch (\Exception $e) {
              $errorCode = $e->getCode();
              echo "#".$errorCode."#";
              }

              ?>

              Comment

              • rouhu
                Member
                • Sep 2020
                • 39

                #22
                I found an easy way to update rates.
                Get rates from ECB at URL

                ​and then create flow in make.com to fetch the rates and call EspoCRM API.

                Comment

                Working...