Skip to content

Step 2. Create additional Source [Web API Tutorial]

Ievgen Shakhsuvarov edited this page Jul 16, 2019 · 13 revisions

The name, source_code, country_id, and postcode attributes are required.

Endpoint
POST http://<host>/rest/all/V1/inventory/sources

Headers
Content-Type application/json
Authorization: Bearer <admin_token>

Payload

{
   "source" : {
      "description" : " Source #17",
      "source_code" : "txspeqs",
      "phone" : "(555) 555-5555",
      "email" : "sales@company.com",
      "postcode" : "77010",
      "longitude" : -95.383056,
      "enabled" : true,
      "contact_name" : "Ethan Carter",
      "latitude" : 29.762778,
      "region_id" : 57,
      "region" : "Texas",
      "name" : "Texas Sport Equipment Source #017",
      "country_id" : "US",
      "city" : "Houston"
   }
}

Response
Magento returns an empty array.
[]

Complete cURL request

source_code_2="txspeqs" && curl -X POST "$endpoint/V1/inventory/sources" \
 -H 'Content-Type: application/json' \
 -H "Authorization: Bearer $admin_token" \
 -d '{"source":{"source_code":"'"$source_code_2"'","name":"Texas Sport Equipment Source #017","email":"sales@company.com","contact_name":"Ethan Carter","enabled":true,"description":" Source #17","latitude":29.762778,"longitude":-95.383056,"country_id":"US","region_id":57,"region":"Texas","city":"Houston","postcode":"77010","phone":"(555) 555-5555"}}'

You can also Create a Source from Admin.

◀️ Previous Step 📖 Table of Contents Next Step ▶️

MSI Documentation:

  1. Technical Vision. Catalog Inventory
  2. Installation Guide
  3. List of Inventory APIs and their legacy analogs
  4. MSI Roadmap
  5. Known Issues in Order Lifecycle
  6. MSI User Guide
  7. DevDocs Documentation
  8. User Stories
  9. User Scenarios:
  10. Technical Designs:
  11. Admin UI
  12. MFTF Extension Tests
  13. Weekly MSI Demos
  14. Tutorials
Clone this wiki locally