Hi,

I'm trying to post data to the mediawiki API and it's not recognising the 
token I am sending.

   var data = querystring.stringify({
              action: "createaccount",
              name: "sean",
              email: "xxx",
              password: "test",
              token: "66cde5ad831521fe9d0fe4df3a2db25f"
        });

        var options = {
            host: '54.201.91.132',
            port: 80,
            path: '/wiki/api.php',
            method: 'POST',
            headers: {
                'Content-Type': 'application/x-www-form-urlencoded',
                'Content-Length': Buffer.byteLength(data)
            }
        };

        var req = http.request(options, function(res) {
            res.setEncoding('utf8');
            res.on('data', function (chunk) {
                console.log("body: " + chunk);
            });
        });

        req.write(data);
        req.end();

I have tried sending the same data using the Postman chrome extension and 
this works fine.

    POST /wiki/api.php HTTP/1.1
    Host: 54.201.91.132
    Cache-Control: no-cache
    Content-Type: application/x-www-form-urlencoded
    
 
action=createaccount&name=shamus&email=xxx&password=test&token=5dc9c943ac3255f87dc7782c24f61ac6&format=json

    {
    "createaccount": {
        "username": "Shamus",
        "userid": 22,
        "token": "c3744c0f19ea62f6baf89b10f7c86f7f",
        "result": "success"
    }
    }

Any ideas what I'm doing wrong?

Thanks,

Sean

-- 
-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to