Using Magento Web Services with the Web Service Connector Tool

TaskCentre can be used to automate calls to the Magento web service, REST or SOAP, using the Web Service Connector tool. Common interactions involve the download of sales orders and inventory, and the upload of order status updates etc.

For the tool to carry out requests on your behalf a set of Magento web access credentials must be supplied, i.e API keys. This article will show you how to obtain the keys from Magento and where they need to be placed within the Web Service Connector tool.

The procedure is different for both REST and SOAP connections.

01 – REST Connections

For a Magento REST connection you must supply the following:

  • Consumer Key
  • Secret Key
  • API Key

Magento – Obtaining the Consumer and Secret Keys

Using the Magento admin panel the Consumer and Secret keys will be created.

  1. Login to the Magento admin panel.
  2. Navigate to System -> Web Services and select REST – OAUTH Consumers.
  3. Click Add New.
  4. Make a note of the Consumer and Secret keys.
  5. Supply a name then click Save to finish.
    Creating New Consumer Keys

Web Service Connector – Generating the API Key

The Consumer and Secret keys can now be passed to the Web Service Connector tool to generate the API key.

  1. Within TakCentre navigate to the Web Service Connector global configuration and open your Magento REST connection: Manage -> Tools -> Execute -> Web Service Connector
  2. Enter the Authentication tab and click the option Open authentication (OAUTH).
  3. Supply the Shared Secret and Consumer Key, obtained earlier.
  4. Select the Signature Method as HMAC-SHA1.
  5. Click Get Access Token and Secret.
  6. Enter the ‘GET Request Token URL root‘ followed by Next:
    http://hostaddress/magento/oauth/initiate
  7. Enter the ‘Login/Authorize Request Token service URL‘ followed by Next:
    http://hostaddress/magento/admin/oauth_authorize
  8. Click the link Launch Web Browser to authorize token. This will open a browser window for you to obtain a ‘verifier code’. When prompted enter your Magento login credentials for the Admin Panel and click Authorize. Make a note of the Verifier code.
  9. Return to the Web Service Connector tool and enter the verifier code into the ‘Verification Code‘ field. Click Next to continue.
  10. Enter the ‘Get Access Token URL‘ followed by Finish:
    http://hostaddress/magento/oauth/token

    WSCT - Authentication Tab

All of the fields under ‘Open authentication (OAUTH)‘ should now be populated, the connection can now be closed.

This completes the procedure of enabling TaskCentre to authenticate with Magento each time a web call is made.

02 – SOAP Connections

For a Magento SOAP connection you must supply the following:

  • User Name
  • API Key

Magento – Creating the User Name and API Key

Though the admin panel a new user will be created along with an API key.

  1. Login to the Magento admin panel.
  2. Navigate to System -> Web Services and select SOAP-XML-RPC-Users.
  3. Click Add New User.
  4. Complete all of the empty fields. The API key is user created and must be more than 6 characters long. The account by default is left as ‘Active‘. Make a note of the User Name and API Key that you just created.
  5. Click Save User to finish.
    SOAP - New User and API

Web Service Connector – Assigning the User Name and API Key to Constants

The User Name and API key will now be created as ‘Constants’ within the Magento SOAP connection at global level. This will enable them for mapping within the Web Service Connector tool and allow them to be mapped to parameters of the web service and passed with each web call.

  1. Within TaskCentre navigate to the Web Service Connector global configuration and open your Magento SOAP connection: Manage -> Tools -> Execute -> Web Service Connector
  2. Enter the Constants tab and create two constants called UserName and APIKey.
    • Under the Name column, click in the blank row and enter ‘UserName‘. Click the next row down and enter ‘APIKey‘.
    • Under the Value colunn, supply the name of the user and the API key you created in Magento.
  3. Click OK to save and finish.
    Creating Constants

Web Service Connector – Mapping the Constants to Parameters in the Web Service

Within the tasks the Constants containing the username and API key must now be mapped to parameters of the Magento web service.

  1. Within the Mapping tab of the Web Service Connector tool, click Functions located on the right-hand side.
  2. Drag a Fixed/Dynamic function into the middle Transformation Mappings pane.
  3. Double-click the function to enter its properties then select the Value tab.
  4. From the task browser and under the Web Service Connector step, expand Constants and drag the UserName constant into the Output Text field.
  5. Click OK to finish.
  6. From the Tool Input pane on the right, expand Authentication and drag the Username parameter onto the username function to complete a mapping.
  7. Complete steps 1-6 to map the APIKey constant to the API key parameter.
    SOAP - Mapping Constants

This completes the procedure of allowing TaskCentre to authenticate with Magento each time a web call is made.

Magento Integration Brochure

Magento Integration Brochure

Learn how integrating Magento with your business software significantly improves order management processes and drives company revenues.

Download Brochure