You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Postman的POST请求中传递数组数据?API传参报错求助

Fixing Your POST API Array Data Issue in Postman

Hey there! Let's get your POST request sorted out and break down how to properly send array data in Postman.

First, Let's Diagnose the Error You're Seeing

Before diving into fixes, let's rule out the most common culprits:

  • Missing/Incorrect Request Header: Make sure your request has Content-Type: application/json set. Postman usually adds this automatically when you select raw JSON, but it's worth double-checking in the Headers tab.
  • JSON Syntax Issues: Your provided data looks valid, but double-check for typos (like missing commas, mismatched curly braces/brackets). You can quickly verify using a built-in JSON checker if needed.
  • Backend Validation Errors: The error might not be from Postman, but from your API. Verify that customer_id: 2 exists in your system, product_id: 1 and 13 are valid product IDs, and shipping_method/payment_method match the allowed values defined on the server side.

Step-by-Step Guide to Sending Array Data in Postman

Here's exactly how to send your order data (including the products array) correctly:

  1. Open Postman and create a new POST request, entering your API endpoint URL.
  2. Go to the Body tab.
  3. Select the raw option, then use the dropdown menu to choose JSON (application/json).
  4. Paste your valid JSON data into the text area:
{
  "orderData": {
    "customer_id": 2,
    "products": [
      {
        "product_id": 1,
        "qty": 1
      },
      {
        "product_id": 13,
        "qty": 1
      }
    ],
    "shipping_method": "flatrate_flatrate",
    "payment_method": "checkmo"
  }
}
  1. Switch to the Headers tab to confirm Content-Type is set to application/json (if not, add it manually as a key-value pair).
  2. Hit the Send button.

Common Pitfalls to Avoid

  • Don't use form-data or x-www-form-urlencoded for sending JSON arrays unless your API explicitly expects data in that format—these are designed for simple key-value pairs, not nested JSON structures.
  • Ensure all string values (like shipping_method) are enclosed in double quotes (single quotes aren't valid JSON syntax).
  • If your API requires authentication (like a bearer token), don't forget to add that in the Headers or Authorization tab before sending the request.

If you're still getting errors, share the exact error message from Postman (or your API's response)—that'll help narrow down the issue further!

内容的提问来源于stack exchange,提问作者Tirth Patel

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.07 09:37:43