Reputation: 1
I am trying to make a JSON Post to the Simpleconsign API, and I keep receiving a 0 error from the browser. Here is my code:
<script type="text/javascript">
JSONTest = function() {
var resultDiv = $("#resultDivContainer");
$.ajax({
type: 'POST',
key: "apikey,
url: 'https://user.traxia.com/app/api/inventory',
contentType: "application/json",
success: function(result){
switch (result) {
case true:
processResponse(result);
break;
default:
resultDiv.html(result);
}
},
error: function (xhr, ajaxOptions, thrownError) {
alert(xhr.status);
alert(thrownError);
}
});
};
</script>
I am a beginner at posting to the REST API's, so any help would be much appreciated. Thank you!
Upvotes: 0
Views: 100
Reputation: 4147
I don't see any data in your Ajax POST? This code should have work
var postData = {
"key": "Your API Key Here",
"query": "some query",
"consignorId": "123456",
"includeItemsWithQuantityZero": "false"
};
JSONTest = function() {
var resultDiv = $("#resultDivContainer");
$.ajax({
type: 'POST',
data: postData,
url: 'https://user.traxia.com/app/api/inventory',
contentType: "application/json",
success: function(result) {
switch (result) {
case true:
processResponse(result);
break;
default:
resultDiv.html(result);
}
},
error: function(xhr, ajaxOptions, thrownError) {
alert(xhr.status);
alert(thrownError);
}
});
};
http://wiki.traxia.com/display/guide/List+and+Search+Inventory
Upvotes: 1