Connect Ionic App to Magento 2.3 REST APIRest API strategy for mobile app in Magento 2DELETE V1/addresses/:addressId - This Rest API is not working with Customer TokenPayment with REST APIREST API accessible without authorizationMagento 2 rest API - How to Manage API Authentication Lifecycle on Mobile Devices Application?Rest API Error “Consumer is not authorized to access %resources”Magento 2 Customer Rest Api Token error for some users [weird problem]rest api are too slow

How can the DM most effectively choose 1 out of an odd number of players to be targeted by an attack or effect?

Example of a relative pronoun

how to create a data type and make it available in all Databases?

How does one intimidate enemies without having the capacity for violence?

Can a German sentence have two subjects?

How is the claim "I am in New York only if I am in America" the same as "If I am in New York, then I am in America?

How old can references or sources in a thesis be?

Why is an old chain unsafe?

A Journey Through Space and Time

Can I make popcorn with any corn?

Showing the closure of a compact subset need not be compact

N.B. ligature in Latex

Extreme, but not acceptable situation and I can't start the work tomorrow morning

How can bays and straits be determined in a procedurally generated map?

Why CLRS example on residual networks does not follows its formula?

Is it legal to have the "// (c) 2019 John Smith" header in all files when there are hundreds of contributors?

What is the offset in a seaplane's hull?

Why are 150k or 200k jobs considered good when there are 300k+ births a month?

Can Medicine checks be used, with decent rolls, to completely mitigate the risk of death from ongoing damage?

Why does not dark matter gather and form celestial bodies?

Chess with symmetric move-square

A newer friend of my brother's gave him a load of baseball cards that are supposedly extremely valuable. Is this a scam?

What is the command to reset a PC without deleting any files

Simulate Bitwise Cyclic Tag



Connect Ionic App to Magento 2.3 REST API


Rest API strategy for mobile app in Magento 2DELETE V1/addresses/:addressId - This Rest API is not working with Customer TokenPayment with REST APIREST API accessible without authorizationMagento 2 rest API - How to Manage API Authentication Lifecycle on Mobile Devices Application?Rest API Error “Consumer is not authorized to access %resources”Magento 2 Customer Rest Api Token error for some users [weird problem]rest api are too slow






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I'm a Magento developer and I need to connect an app developed in Ionic with the Magento 2 REST API. I need to make an extension that grants more access to a customer token, additionally, I need to allow CRUD in custom tables created inside the Magento database. Anyone with some advice?










share|improve this question






























    0















    I'm a Magento developer and I need to connect an app developed in Ionic with the Magento 2 REST API. I need to make an extension that grants more access to a customer token, additionally, I need to allow CRUD in custom tables created inside the Magento database. Anyone with some advice?










    share|improve this question


























      0












      0








      0


      1






      I'm a Magento developer and I need to connect an app developed in Ionic with the Magento 2 REST API. I need to make an extension that grants more access to a customer token, additionally, I need to allow CRUD in custom tables created inside the Magento database. Anyone with some advice?










      share|improve this question
















      I'm a Magento developer and I need to connect an app developed in Ionic with the Magento 2 REST API. I need to make an extension that grants more access to a customer token, additionally, I need to allow CRUD in custom tables created inside the Magento database. Anyone with some advice?







      magento2 extensions rest-api crud ionic






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Feb 26 at 5:00









      Muhammad Hasham

      2,7612831




      2,7612831










      asked Feb 25 at 7:38









      WillBrandsWillBrands

      11




      11




















          1 Answer
          1






          active

          oldest

          votes


















          0














          REST API plays an important role in web apps and is one of the most popular API designs used recently. But for using REST API in Magento 2, you have to know the flow to call APIs in PHP.



          In case you want to use token-based REST API in Magento 2, you will need authenticate, get the token then pass it in the header of every request you perform. Additionally, you also need to create a User Role web service then register the role to a new Admin User in Magento 2.



          We will show you all the tutorials to help you use REST API in Magento 2.



          1. Create Web Service Role:

          2. Login Admin Panel> System> User Roles> Add New Role

          3. Add the Role Name and your current password of Admin in Your
            Password field

          4. Tap Role Resources

          5. Choose what are required for service of your web in Resource Access

          6. Tap Save Role

          7. Create Web Service User in Magento 2

          This user is used for the role you’ve created



          1. Go to System> All Users> Add New User

          2. Fill in all the necessary information

          3. Tap User Role then choose which you’ve created

          4. Tap Save User

          The user above will used to REST API web service in Magento 2.



          Next, we will get starting with Magento 2 REST API.



          Authenticate REST API through Token authentication:Use following code:



          <?php

          //API URL for authentication

          $apiURL="http://example.com/rest/V1/integration/admin/token";

          //parameters passing with URL

          $data = array("username" => "apiaccess", "password" => "password");

          $data_string = json_encode($data);

          $ch = curl_init($apiURL);

          curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");

          curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);

          curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

          curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json","Content-Length: ".strlen($data_string)));

          $token = curl_exec($ch);

          //decoding generated token and saving it in a variable

          $token= json_decode($token);

          ?>


          This code will help pass username and password with API URL in order to authenticate Magento 2 REST API as well as saved the token.



          *Note: The username and password are of what you’ve created



          Get modules in Magento by REST API: By using REST API, you can get most of things in Magento 2. You can check in list of REST APIs for Magento EE and CE.



          Use following code to demonstrate the API:



          <?php

          //Using above token into header

          $headers = array("Authorization: Bearer ".$token);

          //API URL to get all Magento 2 modules

          $requestUrl='http://example.com/rest/V1/modules';

          $ch = curl_init($requestUrl);

          curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

          curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

          $result = curl_exec($ch);

          //decoding result

          $result= json_decode($result);

          //printing result

          print_r($result);

          ?>


          With the code above, you passed the token in the header with the API URL in order to get all the modules installed on Magento 2 store.



          Use following code to print the result:



          <?php

          //API URL for authentication

          $apiURL="http://example.com/rest/V1/integration/admin/token";

          //parameters passing with URL

          $data = array("username" => "apiaccess", "password" => "password");

          $data_string = json_encode($data);

          $ch = curl_init($apiURL);

          curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");

          curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);

          curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

          curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json","Content-Length: ".strlen($data_string)));

          $token = curl_exec($ch);

          //decoding generated token and saving it in a variable

          $token= json_decode($token);

          //******************************************//

          //Using above token into header

          $headers = array("Authorization: Bearer ".$token);

          //API URL to get all Magento 2 modules

          $requestUrl='http://example.com/rest/V1/modules';

          $ch = curl_init($requestUrl);

          curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

          curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

          $result = curl_exec($ch);

          //decoding result

          $result= json_decode($result);

          //printing result

          print_r($result);

          ?>


          We’ve brought you many of tutorials related to Magento 2 REST API. Hope that they are helpful for you.



          source



          Magento 2 REST APIs



          Also for CRUD check Create CRUD For Custom Table






          share|improve this answer























            Your Answer








            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "479"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f263239%2fconnect-ionic-app-to-magento-2-3-rest-api%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            REST API plays an important role in web apps and is one of the most popular API designs used recently. But for using REST API in Magento 2, you have to know the flow to call APIs in PHP.



            In case you want to use token-based REST API in Magento 2, you will need authenticate, get the token then pass it in the header of every request you perform. Additionally, you also need to create a User Role web service then register the role to a new Admin User in Magento 2.



            We will show you all the tutorials to help you use REST API in Magento 2.



            1. Create Web Service Role:

            2. Login Admin Panel> System> User Roles> Add New Role

            3. Add the Role Name and your current password of Admin in Your
              Password field

            4. Tap Role Resources

            5. Choose what are required for service of your web in Resource Access

            6. Tap Save Role

            7. Create Web Service User in Magento 2

            This user is used for the role you’ve created



            1. Go to System> All Users> Add New User

            2. Fill in all the necessary information

            3. Tap User Role then choose which you’ve created

            4. Tap Save User

            The user above will used to REST API web service in Magento 2.



            Next, we will get starting with Magento 2 REST API.



            Authenticate REST API through Token authentication:Use following code:



            <?php

            //API URL for authentication

            $apiURL="http://example.com/rest/V1/integration/admin/token";

            //parameters passing with URL

            $data = array("username" => "apiaccess", "password" => "password");

            $data_string = json_encode($data);

            $ch = curl_init($apiURL);

            curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");

            curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);

            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

            curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json","Content-Length: ".strlen($data_string)));

            $token = curl_exec($ch);

            //decoding generated token and saving it in a variable

            $token= json_decode($token);

            ?>


            This code will help pass username and password with API URL in order to authenticate Magento 2 REST API as well as saved the token.



            *Note: The username and password are of what you’ve created



            Get modules in Magento by REST API: By using REST API, you can get most of things in Magento 2. You can check in list of REST APIs for Magento EE and CE.



            Use following code to demonstrate the API:



            <?php

            //Using above token into header

            $headers = array("Authorization: Bearer ".$token);

            //API URL to get all Magento 2 modules

            $requestUrl='http://example.com/rest/V1/modules';

            $ch = curl_init($requestUrl);

            curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

            $result = curl_exec($ch);

            //decoding result

            $result= json_decode($result);

            //printing result

            print_r($result);

            ?>


            With the code above, you passed the token in the header with the API URL in order to get all the modules installed on Magento 2 store.



            Use following code to print the result:



            <?php

            //API URL for authentication

            $apiURL="http://example.com/rest/V1/integration/admin/token";

            //parameters passing with URL

            $data = array("username" => "apiaccess", "password" => "password");

            $data_string = json_encode($data);

            $ch = curl_init($apiURL);

            curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");

            curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);

            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

            curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json","Content-Length: ".strlen($data_string)));

            $token = curl_exec($ch);

            //decoding generated token and saving it in a variable

            $token= json_decode($token);

            //******************************************//

            //Using above token into header

            $headers = array("Authorization: Bearer ".$token);

            //API URL to get all Magento 2 modules

            $requestUrl='http://example.com/rest/V1/modules';

            $ch = curl_init($requestUrl);

            curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

            $result = curl_exec($ch);

            //decoding result

            $result= json_decode($result);

            //printing result

            print_r($result);

            ?>


            We’ve brought you many of tutorials related to Magento 2 REST API. Hope that they are helpful for you.



            source



            Magento 2 REST APIs



            Also for CRUD check Create CRUD For Custom Table






            share|improve this answer



























              0














              REST API plays an important role in web apps and is one of the most popular API designs used recently. But for using REST API in Magento 2, you have to know the flow to call APIs in PHP.



              In case you want to use token-based REST API in Magento 2, you will need authenticate, get the token then pass it in the header of every request you perform. Additionally, you also need to create a User Role web service then register the role to a new Admin User in Magento 2.



              We will show you all the tutorials to help you use REST API in Magento 2.



              1. Create Web Service Role:

              2. Login Admin Panel> System> User Roles> Add New Role

              3. Add the Role Name and your current password of Admin in Your
                Password field

              4. Tap Role Resources

              5. Choose what are required for service of your web in Resource Access

              6. Tap Save Role

              7. Create Web Service User in Magento 2

              This user is used for the role you’ve created



              1. Go to System> All Users> Add New User

              2. Fill in all the necessary information

              3. Tap User Role then choose which you’ve created

              4. Tap Save User

              The user above will used to REST API web service in Magento 2.



              Next, we will get starting with Magento 2 REST API.



              Authenticate REST API through Token authentication:Use following code:



              <?php

              //API URL for authentication

              $apiURL="http://example.com/rest/V1/integration/admin/token";

              //parameters passing with URL

              $data = array("username" => "apiaccess", "password" => "password");

              $data_string = json_encode($data);

              $ch = curl_init($apiURL);

              curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");

              curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);

              curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

              curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json","Content-Length: ".strlen($data_string)));

              $token = curl_exec($ch);

              //decoding generated token and saving it in a variable

              $token= json_decode($token);

              ?>


              This code will help pass username and password with API URL in order to authenticate Magento 2 REST API as well as saved the token.



              *Note: The username and password are of what you’ve created



              Get modules in Magento by REST API: By using REST API, you can get most of things in Magento 2. You can check in list of REST APIs for Magento EE and CE.



              Use following code to demonstrate the API:



              <?php

              //Using above token into header

              $headers = array("Authorization: Bearer ".$token);

              //API URL to get all Magento 2 modules

              $requestUrl='http://example.com/rest/V1/modules';

              $ch = curl_init($requestUrl);

              curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

              curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

              $result = curl_exec($ch);

              //decoding result

              $result= json_decode($result);

              //printing result

              print_r($result);

              ?>


              With the code above, you passed the token in the header with the API URL in order to get all the modules installed on Magento 2 store.



              Use following code to print the result:



              <?php

              //API URL for authentication

              $apiURL="http://example.com/rest/V1/integration/admin/token";

              //parameters passing with URL

              $data = array("username" => "apiaccess", "password" => "password");

              $data_string = json_encode($data);

              $ch = curl_init($apiURL);

              curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");

              curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);

              curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

              curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json","Content-Length: ".strlen($data_string)));

              $token = curl_exec($ch);

              //decoding generated token and saving it in a variable

              $token= json_decode($token);

              //******************************************//

              //Using above token into header

              $headers = array("Authorization: Bearer ".$token);

              //API URL to get all Magento 2 modules

              $requestUrl='http://example.com/rest/V1/modules';

              $ch = curl_init($requestUrl);

              curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

              curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

              $result = curl_exec($ch);

              //decoding result

              $result= json_decode($result);

              //printing result

              print_r($result);

              ?>


              We’ve brought you many of tutorials related to Magento 2 REST API. Hope that they are helpful for you.



              source



              Magento 2 REST APIs



              Also for CRUD check Create CRUD For Custom Table






              share|improve this answer

























                0












                0








                0







                REST API plays an important role in web apps and is one of the most popular API designs used recently. But for using REST API in Magento 2, you have to know the flow to call APIs in PHP.



                In case you want to use token-based REST API in Magento 2, you will need authenticate, get the token then pass it in the header of every request you perform. Additionally, you also need to create a User Role web service then register the role to a new Admin User in Magento 2.



                We will show you all the tutorials to help you use REST API in Magento 2.



                1. Create Web Service Role:

                2. Login Admin Panel> System> User Roles> Add New Role

                3. Add the Role Name and your current password of Admin in Your
                  Password field

                4. Tap Role Resources

                5. Choose what are required for service of your web in Resource Access

                6. Tap Save Role

                7. Create Web Service User in Magento 2

                This user is used for the role you’ve created



                1. Go to System> All Users> Add New User

                2. Fill in all the necessary information

                3. Tap User Role then choose which you’ve created

                4. Tap Save User

                The user above will used to REST API web service in Magento 2.



                Next, we will get starting with Magento 2 REST API.



                Authenticate REST API through Token authentication:Use following code:



                <?php

                //API URL for authentication

                $apiURL="http://example.com/rest/V1/integration/admin/token";

                //parameters passing with URL

                $data = array("username" => "apiaccess", "password" => "password");

                $data_string = json_encode($data);

                $ch = curl_init($apiURL);

                curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");

                curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);

                curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

                curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json","Content-Length: ".strlen($data_string)));

                $token = curl_exec($ch);

                //decoding generated token and saving it in a variable

                $token= json_decode($token);

                ?>


                This code will help pass username and password with API URL in order to authenticate Magento 2 REST API as well as saved the token.



                *Note: The username and password are of what you’ve created



                Get modules in Magento by REST API: By using REST API, you can get most of things in Magento 2. You can check in list of REST APIs for Magento EE and CE.



                Use following code to demonstrate the API:



                <?php

                //Using above token into header

                $headers = array("Authorization: Bearer ".$token);

                //API URL to get all Magento 2 modules

                $requestUrl='http://example.com/rest/V1/modules';

                $ch = curl_init($requestUrl);

                curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

                curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

                $result = curl_exec($ch);

                //decoding result

                $result= json_decode($result);

                //printing result

                print_r($result);

                ?>


                With the code above, you passed the token in the header with the API URL in order to get all the modules installed on Magento 2 store.



                Use following code to print the result:



                <?php

                //API URL for authentication

                $apiURL="http://example.com/rest/V1/integration/admin/token";

                //parameters passing with URL

                $data = array("username" => "apiaccess", "password" => "password");

                $data_string = json_encode($data);

                $ch = curl_init($apiURL);

                curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");

                curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);

                curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

                curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json","Content-Length: ".strlen($data_string)));

                $token = curl_exec($ch);

                //decoding generated token and saving it in a variable

                $token= json_decode($token);

                //******************************************//

                //Using above token into header

                $headers = array("Authorization: Bearer ".$token);

                //API URL to get all Magento 2 modules

                $requestUrl='http://example.com/rest/V1/modules';

                $ch = curl_init($requestUrl);

                curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

                curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

                $result = curl_exec($ch);

                //decoding result

                $result= json_decode($result);

                //printing result

                print_r($result);

                ?>


                We’ve brought you many of tutorials related to Magento 2 REST API. Hope that they are helpful for you.



                source



                Magento 2 REST APIs



                Also for CRUD check Create CRUD For Custom Table






                share|improve this answer













                REST API plays an important role in web apps and is one of the most popular API designs used recently. But for using REST API in Magento 2, you have to know the flow to call APIs in PHP.



                In case you want to use token-based REST API in Magento 2, you will need authenticate, get the token then pass it in the header of every request you perform. Additionally, you also need to create a User Role web service then register the role to a new Admin User in Magento 2.



                We will show you all the tutorials to help you use REST API in Magento 2.



                1. Create Web Service Role:

                2. Login Admin Panel> System> User Roles> Add New Role

                3. Add the Role Name and your current password of Admin in Your
                  Password field

                4. Tap Role Resources

                5. Choose what are required for service of your web in Resource Access

                6. Tap Save Role

                7. Create Web Service User in Magento 2

                This user is used for the role you’ve created



                1. Go to System> All Users> Add New User

                2. Fill in all the necessary information

                3. Tap User Role then choose which you’ve created

                4. Tap Save User

                The user above will used to REST API web service in Magento 2.



                Next, we will get starting with Magento 2 REST API.



                Authenticate REST API through Token authentication:Use following code:



                <?php

                //API URL for authentication

                $apiURL="http://example.com/rest/V1/integration/admin/token";

                //parameters passing with URL

                $data = array("username" => "apiaccess", "password" => "password");

                $data_string = json_encode($data);

                $ch = curl_init($apiURL);

                curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");

                curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);

                curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

                curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json","Content-Length: ".strlen($data_string)));

                $token = curl_exec($ch);

                //decoding generated token and saving it in a variable

                $token= json_decode($token);

                ?>


                This code will help pass username and password with API URL in order to authenticate Magento 2 REST API as well as saved the token.



                *Note: The username and password are of what you’ve created



                Get modules in Magento by REST API: By using REST API, you can get most of things in Magento 2. You can check in list of REST APIs for Magento EE and CE.



                Use following code to demonstrate the API:



                <?php

                //Using above token into header

                $headers = array("Authorization: Bearer ".$token);

                //API URL to get all Magento 2 modules

                $requestUrl='http://example.com/rest/V1/modules';

                $ch = curl_init($requestUrl);

                curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

                curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

                $result = curl_exec($ch);

                //decoding result

                $result= json_decode($result);

                //printing result

                print_r($result);

                ?>


                With the code above, you passed the token in the header with the API URL in order to get all the modules installed on Magento 2 store.



                Use following code to print the result:



                <?php

                //API URL for authentication

                $apiURL="http://example.com/rest/V1/integration/admin/token";

                //parameters passing with URL

                $data = array("username" => "apiaccess", "password" => "password");

                $data_string = json_encode($data);

                $ch = curl_init($apiURL);

                curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");

                curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);

                curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

                curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json","Content-Length: ".strlen($data_string)));

                $token = curl_exec($ch);

                //decoding generated token and saving it in a variable

                $token= json_decode($token);

                //******************************************//

                //Using above token into header

                $headers = array("Authorization: Bearer ".$token);

                //API URL to get all Magento 2 modules

                $requestUrl='http://example.com/rest/V1/modules';

                $ch = curl_init($requestUrl);

                curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

                curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

                $result = curl_exec($ch);

                //decoding result

                $result= json_decode($result);

                //printing result

                print_r($result);

                ?>


                We’ve brought you many of tutorials related to Magento 2 REST API. Hope that they are helpful for you.



                source



                Magento 2 REST APIs



                Also for CRUD check Create CRUD For Custom Table







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered 13 mins ago









                mahmoudismailmahmoudismail

                4241426




                4241426



























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Magento Stack Exchange!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f263239%2fconnect-ionic-app-to-magento-2-3-rest-api%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Nidaros erkebispedøme

                    Birsay

                    Where did Arya get these scars? Unicorn Meta Zoo #1: Why another podcast? Announcing the arrival of Valued Associate #679: Cesar Manara Favourite questions and answers from the 1st quarter of 2019Why did Arya refuse to end it?Has the pronunciation of Arya Stark's name changed?Has Arya forgiven people?Why did Arya Stark lose her vision?Why can Arya still use the faces?Has the Narrow Sea become narrower?Does Arya Stark know how to make poisons outside of the House of Black and White?Why did Nymeria leave Arya?Why did Arya not kill the Lannister soldiers she encountered in the Riverlands?What is the current canonical age of Sansa, Bran and Arya Stark?