Skip to Content

jquery ajax post send json

Hi everybody,

I'm trying to develop an application for a blockchain scenario (digital asset transfer) but unfortunately when I launch the app I get an error (403 forbidden).

If I execute the json-rpc call with Postman, everything works fine but if I use the following code in the controller.js in Web IDE it doesn't work.

I have already set up the destination in SCP and in the neo-app.json.

Could you please help me to solve this issue?

jQuery.ajax({
	type: "POST",
	url: "/blockchainasset/*******************************/rpc",
	beforeSend: function (request) {
	request.setRequestHeader("apikey", "************************");
	},
	data: JSON.stringify({
	     "method": "getaddresses"
	}),
	dataType: "json",
	contentType: "application/json",
	success: function (data, textStatus, jQxhr) {
		console.log(data);
	},
	error: function (jqXhr, textStatus, errorThrown) {
		console.log(errorThrown);
	}
});
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • Best Answer
    Sep 14 at 01:22 PM

    Hi Davide,

    there seems to be a solution for this problem:

    Please try to whitelist the APIKEY header field by adding the following entry to the neo-app.json:

    "headerWhiteList": ["APIKEY"]

    Add comment
    10|10000 characters needed characters exceeded

  • Sep 03 at 10:07 AM

    i would say this is related to the destination, what is the error you are seeing in the network tab? check the url is formed correctly

    Add comment
    10|10000 characters needed characters exceeded

  • Sep 03 at 12:08 PM

    I think that the main problem is the authentication in your destination.

    Are you using the SAP Blockchain service?

    Add comment
    10|10000 characters needed characters exceeded

  • Sep 12 at 05:59 PM

    Hi Davide.

    This most likely seems to be a CORS problem.

    You won't be able to call MultiChain RPC Endpoint using only a frontend application because of security concerns.

    Greetings,

    Alex

    Add comment
    10|10000 characters needed characters exceeded