1

I need to pull inventory data from a third-party site a client uses and display that data on their website using the REST API. I've been looking around but haven't found a clear way to do this.

I need to make a Get Request from: https://user.traxia.com/app/api/inventory

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

I would like the response to be

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

The documentation they list is here http://wiki.traxia.com/display/guide/List+and+Search+Inventory

Since I don't know how to accomplish this, any help would be great! Code examples greatly appreciated!

hex494D49
  • 9,109
  • 3
  • 38
  • 47
pdxdesigner
  • 11
  • 1
  • 3
  • 1
    See http://stackoverflow.com/questions/247483/http-get-request-in-javascript – fasouto Jul 10 '14 at 22:40
  • 1
    I believe this [sending and retrieving json with ajax](http://stackoverflow.com/questions/24468459/sending-a-json-to-server-and-retrieving-a-json-in-return-without-jquery/24468752#24468752) is what you're looking for. – hex494D49 Jul 10 '14 at 22:45

1 Answers1

0

Like the answer fasouto linked to explains, this jQuery method should get you the JSON results you want:

$.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"
);
VinceFior
  • 1,279
  • 13
  • 25
  • I want to display the returned data to site visitors. How can I display the data that is returned? – pdxdesigner Jul 16 '14 at 20:54
  • The simplest way to display the data is to set the text of an HTML element in the `function(data)` method I wrote. You can do this in jQuery with the `text` method. Here's a tutorial that explains it: http://www.w3schools.com/jquery/html_text.asp – VinceFior Jul 16 '14 at 21:10