Created
May 24, 2018 06:27
-
-
Save rparsi/3423aaa04477cd4dab61f17582a1bfb4 to your computer and use it in GitHub Desktop.
Magento2 Rest API Usage
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # to get admin user api token | |
| curl -X POST "http://localhost.magento2.com/index.php/rest/V1/integration/admin/token" -H "Content-Type:application/json" -d '{"username":"admin", "password":"admin123"}' | |
| # example api token: gltdyin7xidjpmkgn2afd5p945hry64d | |
| # use countries api | |
| curl -X GET "http://localhost.magento2.com/index.php/rest/V1/directory/countries" -H "Authorization: Bearer c4chlm8e9j819mss4x1f6hs5jvdu7syp" | |
| # create customer | |
| curl -X POST http://localhost.magento2.com/index.php/rest/V1/customers" -H "Content-Type:application/json" -H "Authorization: Bearer ich23vrq4be4yj671j6u1bx12r3n03u7" -d '{"customer":{"email":"rparsi@commer.com","firstname":"Rahi","lastname":"Parsi","dob":"1976-11-28","storeId":1,"websiteId":1},"password":"Admin123"}' | |
| # update customer | |
| curl -X PUT http://localhost.magento2.com/index.php/rest/V1/customers/99" -H "Content-Type:application/json" -H "Authorization: Bearer ich23vrq4be4yj671j6u1bx12r3n03u7" -d '{"customer":{"extension_attributes":{"is_subscribed":true}}}' | |
| # customer search | |
| curl -X GET http://localhost.magento2.com/index.php/rest/V1/customers/search?searchCriteria[filterGroups][0][filters][0][field]=email&searchCriteria[filterGroups][0][filters][0][value]=rparsi@commer.com&searchCriteria[filterGroups][0][filters][0][condition_type]=eq" -H "Content-Type:application/json" -H "Authorization: Bearer ich23vrq4be4yj671j6u1bx12r3n03u7" | |
| # making soap call with curl | |
| curl -X POST -H "Content-Type: text/xml;charset=UTF-8" -H "SOAPAction: \"http://localhost.domain.com/soap\"" --data-binary @request.xml http://localhost.domain.com/soap | |
| curl -X POST -H "Content-Type: text/xml;charset=UTF-8" --data-binary @request.xml http://localhost.domain.com/soap |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment