- Select Connection Type as HTTP.
- Select Authentication Type as Token.
- Enter the rest of the fields as explained below:
-
Authentication Fail Status Code: 200
- [Since Magento1 returns 200 code for all requests(success or failures), we need to tell integrator.io how to identify which is the authentication failed response so that it can auto retry to get another token/session]
-
Authentication Fail Path: /*[local-name()='Envelope']/*[local-name()='Body']/*[local-name()='Fault']/*[local-name()='faultcode']/text()
- [Magento1 returns the error code in above path]
-
Authentication Fail Values: 5
- [5 is the error code for session expired error. When integrator.io will see 5 in the error path, it will know it needs to get another session id using Refresh Token Configuration]
-
Base URI: https://<YOUR BASE URI>/index.php/api
- [Enter above url and replace <YOUR BASE URI> with your Magento base uri]
- Media Type: XML
-
Unencrypted: {"username": "<YOUR SOAP API USERNAME>"}
- [an example would be {"username": "celigo-aa-ws"}. This is the SOAP API user you create in Magento]
-
Encrypted: {"password": "<YOUR SOAP API PASSWORD>"}
- [an example would be {"password": "celigo4aaws"}. This is the SOAP API key you create in Magento]
-
Token: <some random string>
- [just provide some random string here like 123. Integrator.io will first use this token/session id to test the connection and if it returns session expired error, then it will try to refresh the token explained in below steps]
4. Under ‘How to Send Token’, set the ‘Location’ as Body and check ‘Configure Token Refresh’ as true. This will tell integrator.io to send the token/session id in the body of the request xml and also adds the refresh token logic.
5. Under ‘How to Refresh Token?’, set the fields as explained below:
- Refresh Token: <some random string>
- [just provide some random string here like 123. Integrator.io will first use the ‘Token’ given in step 3 and then this refresh token/session id to test the connection and if Magento still returns session expired error, then it will try to refresh the token and save it in this ‘Refresh Token’ field for next use]
-
Refresh Relative URI: /v2_soap/index
- [you can either use v1 soap uri '/index/index' or v2 soap uri '/v2_soap/index' to get the new session id]
- Refresh Media Type: XML
- Refresh Method: POST
-
Refresh Body: <?xml version='1.0' encoding='UTF-8'?><soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'><soapenv:Body><ns1:login soapenv:encodingStyle='http://schemas.xmlsoap.org/soap/encoding/' xmlns:ns1='urn:Magento'><username xsi:type='xsd:string'>{{{connection.http.unencrypted.username}}}</username><apiKey xsi:type='xsd:string'>{{{connection.http.encrypted.password}}}</apiKey></ns1:login></soapenv:Body></soapenv:Envelope>
- [this is the Magento login request body to get the new session id. Note that we are reading API user and key from the encrypted/unencrypted fields set in step 3 above]
-
Refresh Token Path: /*[local-name()='Envelope']/*[local-name()='Body']/*[local-name()='loginResponse']/*[local-name()='loginReturn']/text()
- [this is the xpath for the session id in the response]
6. Under ‘How to test the connection?’, you can use any API method to test the connection. Below is an example to get product info using soap v2 API.
- Ping Relative URI: /v2_soap/index
- Ping Method: POST
- Ping Body: <soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:Magento" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
<soapenv:Header/>
<soapenv:Body>
<urn:catalogProductInfo soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<sessionId xsi:type="xsd:string">{{{connection.http.auth.token.token}}}</sessionId>
<productId xsi:type="xsd:string">2896</productId>
<storeView xsi:type="xsd:string">1</storeView>
<identifierType xsi:type="xsd:string">id</identifierType>
</urn:catalogProductInfo>
</soapenv:Body>
</soapenv:Envelope>
-
- [this is a sample v2 SOAP request body to get product info of product id 2896. If your Magento does not contain any product with this id, you can try giving some valid product id for store view 1]
- Ping Success Path: /*[local-name()='Envelope']/*[local-name()='Body']/*[local-name()='catalogProductInfoResponse']/*[local-name()='info']/*[local-name()='product_id']/text()
- Ping Error Path: /*[local-name()='Envelope']/*[local-name()='Body']/*[local-name()='Fault']/*[local-name()='faultstring']/text()
7. Now ‘Test’ the connection and ‘Save’ it once confirmed working. If there is any error while testing the connection, you should see it as a pop up. An example error would be product id does not exist in your system.
- In this case, give some valid product id which exists in your system to ensure the connection test is working fine.
- Once the connection is setup, you can use this in your imports/exports. While building a http request body in your imports/exports, make sure you pass sessionId value as {{{connection.http.auth.token.token}}}.
- If there is a need to update the base uri, just update the ‘Base URI’ field with new domain, enter the ‘Encrypted’ Json string again, give some random string in ‘Token’ and ‘Refresh Token’ fields and hit ‘Test’. Save the connection once tested.
Comments
Please sign in to leave a comment.