1

I am developing code to generate labels for Flipkart orders which orders I am getting from Flipkart orders API. while calling this URL https://api.flipkart.net/sellers/v3/shipments/labels, I am getting a response invalid JSON. Below code that I tried. Anyone who developed Flipkart API and face this issue before kindly help.

I refer Flipkart API Docs https://seller.flipkart.com/api-docs/fmsapi_index.html

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.flipkart.net/sellers/v3/shipments/labels',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{
  "shipments": [
    {
      "shipmentId": "8f68421b-37cc-4862-aeda-52aeefe121811a6",
      "locationId": "",
      "taxItems": [
        {
          "orderItemId": "12406434662285585103",
          "taxRate": 5.0,
          "quantity": 1
        }
      ],"serialNumbers": [
        {
          "orderItemId": "12406434662285585103",
          "serialNumbers": [
            []
          ]
        }
      ],
      "invoices": [
        {
          "shipmentId": "8f68421b-37cc-4862-aeda-52aeefe121811a6",
          "invoiceDate": "2022-02-02",
            "invoiceNumber": "",
         "orderItems": [
            {
              "orderItemId": "12406434662285585103",
              "invoiceAmount": 939.00,
              "taxRate": 5.0,
              "serialNumbers": [
                []
              ],
              "taxDetails": {
                "cgstRate": 0.0,
                "sgstRate": 0.0,
                "igstRate": 5.0
              }
            }
          ]
        }
      ],
      "subShipments": [
        {
          "subShipmentId": "SS-1",
          "dimensions": {
            "length": 25,
            "breadth": 20,
            "height": 5,
            "weight": 0.3
          }
        }
      ]
    }
  ]
}',
  CURLOPT_HTTPHEADER => array(
    'Authorization: Bearer 89',
    'Content-Type: application/json'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;


**Response** 

{
    "code": 400,
    "message": "Unable to process JSON"
}

0 Answers0