Dart HttpClient is not POSTing -


i'm trying consume data zabbix service. worked nodejs dart receive nothing. maybe i'm missing something, i've spent lot of time part of app. i'm using m4 dart editor (which great way). dart code:

const string path = "http://someip/zabbix/api_jsonrpc.php";  map zabbix = {       "jsonrpc": "2.0",       "method": "user.authenticate",       "params": {         "user": "user",         "password": "password"       },       "id": 1,       "auth": null     };  httpclient cliente = new httpclient();      cliente.posturl( new uri.fromstring( path ))         .then(( httpclientrequest req ) {           req.headers.contenttype = new contenttype( "application", "json-rpc", charset: "utf-8" );           req.headers.add( httpheaders.connection, "keep-alive");           req.write( json.stringify( zabbix ));           return req.close();       }).then(( httpclientresponse res ) {         streamsubscription st = res.listen( null );          st.ondata(( chunk ) => print( chunk));       }); 

and nodejs code:

var opt = {         host: 'someip',         path: '/zabbix/api_jsonrpc.php',         method: 'post',         headers: {             'content-type': 'application/json-rpc'         }     };  var zabbix = {             "jsonrpc": "2.0",             "method": "user.authenticate",             "params": {                 "user": "user",                 "password": "password"             },             "id": 1,             "auth": null         },         req = http.request(opt, function( res ) {           res.setencoding('utf8');            res.on('data', function(chunk) {             console.log(chunk);           });         });      req.write(json.stringify(zabbix), 'utf8');     req.end(); 

import 'dart:convert'; 

and

cliente.posturl( uri.parse( path ))   .then(( httpclientrequest req ) {     req.headers.contenttype = new contenttype( "application", "json-rpc", charset: "utf-8" );     req.headers.add( httpheaders.connection, "keep-alive");     req.write( json.encode( zabbix ));     return req.close();   }).then(( httpclientresponse res ) {     streamsubscription st = res.listen( null );      st.ondata(( chunk ) => print( chunk)); }); 

Comments

Popular posts from this blog

node.js - Bad Request - node js ajax post -

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -