HTTP GET请求JSON响应- REST API

HTTP GET Request JSON response - REST API

本文关键字:REST API 响应 JSON GET 请求 HTTP      更新时间:2023-09-26

我需要从客户端使用的第三方站点提取库存数据,并使用REST API在他们的网站上显示该数据。我一直在四处寻找,但还没有找到一个明确的方法来做到这一点。

我需要做一个Get请求:https://user.traxia.com/app/api/inventory

// request
{
    "key": "API Key Here",
    "query": "CAMERA", 
    "consignorId": "false",
    "includeItemsWithQuantityZero": false
}

我希望响应为

{
    "results":
    [
        {
            "status":"ACTIVE"
            "sku":"",
            "name":"",
            "cost":0
        }
    ]
}

他们列出的文档在这里http://wiki.traxia.com/display/guide/List+and+Search+Inventory

既然我不知道如何完成这个,任何帮助将是伟大的!代码示例非常感谢!

就像fasouto链接到的答案一样,这个jQuery方法应该可以得到您想要的JSON结果:

$.get(
    "https://user.traxia.com/app/api/inventory",
    {key : 'API Key Here', 
     query : 'CAMERA',
     consignorId : false,
     includeItemsWithQuantityZero : false},
    function(data) {
        // data is a JSON object with the results you expect
    },
    "json"
);