I'm trying to call a contract with Nethereum. I know the contract works because I am able to call it with Web3.JS. However whenever I try to call it with Nethereum, I pass in the following paramenters.
conn = new Web3(url);
contract = conn.Eth.GetContract(abi, address);
Function castVote = contract.GetFunction("castVote");
var result = await castVote.SendTransactionAsync(account, null, null, account, candidate);
I get the following exception without much of an explanation...
Nethereum.JsonRpc.Client.RpcClientUnknownException: Error occurred when trying to send rpc requests(s) ---> Newtonsoft.Json.JsonSerializationException: Required property 'code' not found in JSON. Path 'error', line 1, position 6776.
What would cause this? I can't find anything online.
Related
i have used the following code inside of a function, and i am returning the responce
image = vision.types.Image(content=content)
print("vision type: %s" %vision.enums.Feature.Type.DOCUMENT_TEXT_DETECTION)
feature = vision.types.Feature(type=vision.enums.Feature.Type.DOCUMENT_TEXT_DETECTION)
print(type(feature))
response = client.text_detection(image=image,features=
[{'type':str(vision.enums.Feature.Type.TEXT_DETECTION)}], image_context=
{"language_hints":
["en"]})
Error at this line:
response = client.text_detection(image=image,features=
[{'type':str(vision.enums.Feature.Type.TEXT_DETECTION)}], image_context={"language_hints":
["en"]})
request = dict(image=image, features=[copied_features], **kwargs)
TypeError: type object got multiple values for keyword argument 'features'
NOTE:
I have visited their documentation page, however that is outdated,and I specifically wants to set the feature type to either "DOCUMENT_TEXT_DETECTION" or "TEXT_DETECTION"
Change it to:
response = client.text_detection(image=image, image_context=
{"language_hints":
["en"]})
You already have text_detection in this request, you trying to set in again.
Example
Using methods like text_detection or document_text_detection you already declare type.
Use annotate_image to declare entire request json and declare type_ there:
response = client.annotate_image(
{
"image": {"content": image},
"features": [{"type_": "DOCUMENT_TEXT_DETECTION"}],
"image_context": {"language_hints": ["en"]},
}
)
I'm learning node, and I'm having a hard time writing the back-end code for my database interactions. A promise based implementation looked a lot cleaner than doing it all using callbacks, so I did some digging and found Q.
I'm having trouble understanding what I'm doing wrong here, or even where. The error function inside .then seems to be catching the TypeCast error, but I don't know what I'd be doing that would be causing that error?
Running the following script
mysql = require('mysql');
var q = require('q')
var dbx = mysql.createConnection({
//this is verified correct...
});
function getuser3(UserDisplayName) {
return q.nfcall(dbx.query, "SELECT * FROM Users WHERE Name = ? ", [UserDisplayName])
// This should wrap the query function with a promise, apply the arguments "SELECT..." ,
// [UserDisplayName], and set up the last-argument-node-style callback so it fulfills the promise
// with either a value or an error. If I understand correctly.
}
val = getuser3("Player2")
.then(
function (value) {
console.log(value)
return value //this should be sent to val in the outside scope, right?
},
function (error) {
console.log(error)
}
)
.done()
console.log(val)
Returns the following error:
c:\Users\cb\Documents\guts\learning node\backend\node_modules\q\q.js:155
throw e;
^
TypeError: Cannot read property 'typeCast' of undefined
at query (c:\Users\cb\Documents\guts\learning node\backend\node_modules\mysql\lib\Connection.js:185:34)
at Promise.apply (c:\Users\cb\Documents\guts\learning node\backend\node_modules\q\q.js:1185:26)
at Promise.promise.promiseDispatch (c:\Users\cb\Documents\guts\learning node\backend\node_modules\q\q.js:808:41)
at c:\Users\cb\Documents\guts\learning node\backend\node_modules\q\q.js:1411:14
at runSingle (c:\Users\cb\Documents\guts\learning node\backend\node_modules\q\q.js:137:13)
at flush (c:\Users\cb\Documents\guts\learning node\backend\node_modules\q\q.js:125:13)
at processTicksAndRejections (internal/process/task_queues.js:79:11)
Process exited with code 1
I've tried several variations of the syntax, reading the docs as best I could, but I really don't know where to go next.
I am trying to invoke an HTTP triggered Azure function built on with a GET request. I setup the linked service as per the recommended steps and the function itself works with a query string through POSTMAN or internet browser, but fails when I try to invoke through Data factory.
{
"errorCode": "3608",
"message": "Call to provided Azure function '' failed with status-'NotFound' and message - 'Invoking Azure function failed with HttpStatusCode - NotFound.'.",
"failureType": "UserError",
"target": "Azure Function1",
"details": []
}
I came across another stackoverflow post https://stackoverflow.com/a/54497119/4212430 where there was a mention of a JSON response for ADF.
I have since changed my python code to provide an HTTP response as a JSON object as below
def main(req: func.HttpRequest) -> func.HttpResponse:
logging.info('Python HTTP trigger function processed a request.')
statename = req.params.get('statename')
if not statename:
try:
req_body = req.get_json()
except ValueError:
pass
else:
statename = req_body.get('statename')
if statename:
initiate_main(statename)
host.close()
function_message = {"Response":"Successfully trasnferred BOM files"}
return func.HttpResponse(
json.dumps(function_message),
mimetype="application/json",
status_code=200)
else:
function_message = {"Response":"Error in transferring files"}
return func.HttpResponse(
json.dumps(function_message),
mimetype="application/json",
status_code=400)
But that hasn't helped either.
It turns out that I was using the wrong URI with an api added at the end while I should have just been giving the plain function name
I have a need in my code to perform an AJAX request and send the resulting data to two different places, so I figured using a multicast observable was the easiest way of achieving this. My code looks like this:
In the constructor for my 'app' object:
this.getEpisodeDescription = (id) => jsonLoader("http://www.randomtext.me/api/lorem/p-2/8-24", "text_out");
function jsonLoader (url, field)
{
let stream = Rx.Observable.ajax ({ url: url, crossDomain: true })
.retry (1)
.pluck ("response");
if (field !== undefined)
return stream.pluck(field);
else
return stream;
}
I've successfully used this method before to retrieve data for a single receiver, so I'm sure this is working OK. The caller is new, however:
loadSummary (id)
{
let cachedValue = this.summaries.get(id);
if (cachedValue !== undefined) return Rx.Observable.of(cachedValue);
let observable = this.app.getEpisodeDescription(id);
let multicast = observable.multicast ().refCount ();
multicast.subscribe(result => this.summaries.put(id, result));
return multicast;
}
When I try executing this method, I get the following stack trace:
Uncaught TypeError: Cannot read property 'subscribe' of undefined
at Observable.ConnectableObservable._subscribe (app.js:44193)
at Observable._trySubscribe (app.js:10253)
at Observable.subscribe (app.js:10241)
at RefCountOperator.call (app.js:44275)
at Observable.subscribe (app.js:10238)
at AsyncAction.SubscribeOnObservable.dispatch (app.js:71532)
at AsyncAction._execute (app.js:21083)
at AsyncAction.execute (app.js:21058)
at AsyncScheduler.flush (app.js:21156)
(Ignore file name and line numbers -- I'm using webpack and it doesn't seem to be producing a working line number map at the moment)
Any ideas what's going on? Specifically, how does it happen that I get an object out of the call to multicast that has appropriate subscribe etc methods, but when you try to subscribe to it it apparently can't subscribe to the parent?
The first parameter to the multicast() operator is either Subject factory function or a Subject instance.
This means you should be using it like this if you want to have one shared Subject instance:
let multicast = observable.multicast(new Subject()).refCount();
... or like this to make a new Subject for every observer:
let multicast = observable.multicast(() => new Subject()).refCount();
I've read the Feathers book, so I know that to create an error response I simply instantiate the appropriate feathers-errors class:
import {BadRequest} from 'feathers-errors';
const errorResponse = new BadRequest(`foo`, `bar`);
However, I'm having difficulty returning that error response to the user. Even when I create an endpoint that does nothing but return an error response ...
class SomeService {
create(data) {
return new BadRequest(`foo`, `bar`);
}
}
it doesn't work: instead of getting an error response, I get no response, and inside the Chrome debugger I can see that the response is pending (until it eventually times out and becomes an ERR_EMPTY_RESPONSE).
I tried reading about Express error handling, and in the examples I saw people used next to wrap the the response. However, next comes from the error handler, and I'm not sure where in my Feathers code I can get that next function.
If anyone could help explain (using next or not) how I can return a complete, not pending, error response, I would greatly appreciate it.
Your services have to return a promise. If your code is not asynchronous you can turn it into a promise with Promise.resolve and Promise.reject:
class SomeService {
create(data) {
return Promise.reject(new BadRequest(`foo`, `bar`));
}
}
Also make sure you registered the Express error handler to get nicely formatted errors:
const errorHandler = require('feathers-errors/handler');
// Last in the chain
app.use(errorHandler);
There is also more information in the error handling chapter.