You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to call the NEO Oracle using the sample smart contract below:
using Neo.SmartContract.Framework.Services;
using Neo.SmartContract.Framework.Attributes;
using Neo.SmartContract.Framework.Native;
using System;
namespace Neo.SmartContract.Examples
{
[ManifestExtra("Author", "Neo")]
[ManifestExtra("Email", "[email protected]")]
[ManifestExtra("Description", "This is an oracle example")]
public class OracleDemo : Framework.SmartContract
{
public static void doRequest()
{
string url = "https://raw.githubusercontent.com/neo-project/examples/master/csharp/Oracle/example.json"; // the content is { "value": "hello world" }
string filter = "$.value"; // JSONPath format https://github.com/atifaziz/JSONPath
string callback = "callback"; // callback method
object userdata = "userdata"; // arbitrary type
long gasForResponse = Oracle.MinimumResponseFee;`
Oracle.Request(url, filter, callback, userdata, gasForResponse);
}
public static void callback(string url, string userdata, OracleResponseCode code, string result)
{
if (Runtime.CallingScriptHash != Oracle.Hash) throw new Exception("Unauthorized!");
if (code != OracleResponseCode.Success) throw new Exception("Oracle response failure with code " + (byte)code);
object ret = StdLib.JsonDeserialize(result); // [ "hello world" ]
object[] arr = (object[])ret;
string value = (string)arr[0];
Runtime.Log("userdata: " + userdata);
Runtime.Log("response value: " + value);
}
}
}
However, I'm getting a message that the Oracle is failing: "Oracle response failure with code "
Per asking people on Discord, the key issue is that the Oracle website isn't setting Content-Type header to application/json. Instead its setting it to text/plain; charset=utf-8. Per the blockchain explorer, transaction had an exception VMState == FAULT error is ContentTypeNotSupported.
However, I cannot make this change from my end, it needs to be done from the website.
Can someone here please confirm that this is the root cause of the error, and if so, provide a work-around or fix the problem directly on the Oracle website? For reference, my smart contract is deployed on TestNet here, if you'd like to test it directly:
Hi!
I'm trying to call the NEO Oracle using the sample smart contract below:
However, I'm getting a message that the Oracle is failing:
"Oracle response failure with code "
Per asking people on Discord, the key issue is that the Oracle website isn't setting
Content-Type header to application/json
. Instead its setting it totext/plain; charset=utf-8
. Per the blockchain explorer,transaction had an exception VMState == FAULT error is ContentTypeNotSupported
.However, I cannot make this change from my end, it needs to be done from the website.
Can someone here please confirm that this is the root cause of the error, and if so, provide a work-around or fix the problem directly on the Oracle website? For reference, my smart contract is deployed on TestNet here, if you'd like to test it directly:
https://dora-dev.coz.io/transaction/neo3/testnet/0xc94e32026d03e2b5408bd28cd7b9e9022a3b08fe9337d94a366563870c02dd5a
Thanks,
The text was updated successfully, but these errors were encountered: