I am having issues with the api and I've tried lots of things and nothing seems to be working. I used their https://api.random.org/json-rpc/1/request-builder JSON object creator to make sure I was doing the JSON correctly. I have looked over my JSON request and I think the issue lays there.
Here is my code:
$.ajax({
url: 'https://api.random.org/json-rpc/1/invoke',
type:"POST",
data:{
'jsonrpc': '2.0',
'method': 'generateIntegers',
'params': {
'apiKey': '00000000-0000-0000-0000-000000000000',
'n': 10,
'min': 1,
'max': 10,
'replacement': true,
'base': 10
},
'id': 2601
},
contentType:"application/json; charset=utf-8",
dataType:"json",
success: function(result){
$('#text').html(JSON.stringify(result));
console.log(result);
}
});
The key is 0'ed out for example.
The response I get is this:
{"jsonrpc":"2.0","error":{"code":-32700,"message":"Parse error","data":null},"id":null}
And the websites error code sheet says the message is due to parsing error, and the data I grabbed is sure to be correct so that just leaves it down to.. I'm sending it wrong? I must be sending this data .. not how it wants me too and I believe that has something to do with my JSON request headers.
I know I could just use Maths.random(), or probably rip their entire demonstration page, but they use a bunch of HTML forms and this should just be simple Ajax.. Right?