How to create shipment using Rest API Magento 2?

Magento 2 is robust, scalable and multi-feature enable eCommerce platform. You can create Shipment of an Order Using a third party platform to Magento 2 backend by API request.
Using below payload you can create Shipment of an order using any third party platform to Magento 2. you Just need to pass below payload in your request with POST data. Check for creating an order using API,  Create order using rest api in Magento 2

Request:
{YOUR_URL}/rest/V1/order/{order_id}/ship

Type:
POST

Body:

{
    "items": [
      {
        "order_item_id": 10,
        "qty": 1
      }
    ],
    "notify": true,
  	"appendComment": true,
    "comment": {
	    "extension_attributes": {},
	    "comment": "comment on shipment",
	    "is_visible_on_front": 1
	   },
    "tracks": [
      {
        "track_number": "123456",
        "title": "fedex Shipment",
        "carrier_code": "fedex"
      }
    ]    
}

Pass order item id is your order item’s id dont pass order id. Pass order_id in request Url. You can create multiple request using pass multi-array in the items array.

Response:
10 (new shipment id)

 

How to create order using /V1/orders/create Rest API Magento 2?

Create Sales Order by REST API Magento 2 is useful to generate dynamic orders from the third-party platform in Magento System.

You can create an order using the required value from the given Payload. Send Payload in your request with PUT action.

For the Demonstrate purpose pass data like Shipping method, Flatrate shipping, Added Custom discount Shopping cart Rule, and COD as a payment method in payload request. Continue reading “How to create order using /V1/orders/create Rest API Magento 2?”

How to use php curl as best practice in magento 2?

In Magento 2, We can get details about curl from Curl.php file at location Magento\Framework\HTTP\Adapter\Curl.

Magento gives native functionality for CURL instead of using default php curl_init().
We can send a request to third party services using curl by below way,
Continue reading “How to use php curl as best practice in magento 2?”