1

我正在开发代码来为 Flipkart 订单生成标签,这些订单是我从 Flipkart 订单 API 获得的订单。在调用此 URL https://api.flipkart.net/sellers/v3/shipments/labels时,我收到响应无效的 JSON。下面是我尝试过的代码。任何开发过 Flipkart API 并在此之前遇到此问题的人,请提供帮助。

我参考 Flipkart API 文档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"
}
4

0 回答 0