Created
May 11, 2017 16:13
-
-
Save yvoronoy/a11cc36aba77455e7ea34bd123f1f93c to your computer and use it in GitHub Desktop.
Magento2 API Examples
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
#!/bin/bash | |
# CREATE CATEGORY REST API | |
TOKEN= | |
BASE_URL=$1 | |
echo $BASE_URL | |
TOKEN=$(curl -X POST "${BASE_URL}index.php/rest/V1/integration/admin/token" \ | |
-H "Content-Type:application/json" \ | |
-d '{"username":"admin", "password":"123123q"}') | |
TOKEN=$(echo $TOKEN | sed "s/\"//g"); | |
echo TOKEN: ${TOKEN} | |
curl -X POST "${BASE_URL}index.php/rest/V1/categories" \ | |
-H "authorization: Bearer ${TOKEN}" \ | |
-H 'content-type: application/json' \ | |
-d '{ | |
"category": | |
{ | |
"name": "New Arrival", | |
"parent_id":2, | |
"isActive": true, | |
"include_in_menu": true, | |
"custom_attributes": [ | |
{"attribute_code": "url_key","value": "new-arrival"} | |
] | |
}, | |
"saveOptions": true | |
}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment