Trying to add a card to trelolo fails

I am trying to add a map to trello using a Node.js script. Other calls (all so far) to the trello system seem to work, but this one just doesn't return any response at all. I tried plugging it into the API tester (postman) and I am returning this error message:

This looks like a bug related to http: // URL : https://api.trello.com/1/cards?name=TestCard&pos=top&due=null&idlist= [listid ]&key= [key ]&token= [token] . The response status was 0. Check out the W3C XMLHttpRequest Level 2 specification for more information on when this will happen.

Edit: Postman now returns the correct answer (in 0.5s), with the change to capitalization prompted in the comments below. However, my code expires after 3 seconds. So something is wrong in the code.

This is the first post call I tried to implement, so it might be a problem here. My code looks like this:

var options = {
  hostname: api.trello.com, 
  port: 443,
  path: '/1/cards?name=TestCard&pos=top&due=null&idList=[listid]&key=[key]&token=[token]',
  method: 'POST',
  headers: { 'Content-Type': 'application/json'}
};
https.request(options, function(res) {
    var ResponseString = '';
    console.log("statusCode: ", res.statusCode);
    console.log("headers: ", res.headers);
    //and more code here
});

      

The res.on ('data') and res.on ('end') functions have console.log and are not called. The .logs console from this function is not called either.

I've also tried lists / [ListID] / cards? due = null & name = [CardTitle] url, without any response from that.

Is there something I need to know about posting from Node.js that I'm missing here?

+3


source to share


1 answer


https.request

returns an object ClientRequest

. You can use this object to add a body to the request (with req.write()

). But more importantly, the request will not complete until you call req.end()

; he expects you haven't finished body tuning yet if you can't call it.



+1


source







All Articles