Back to LanguageTool Homepage - Privacy - Imprint

API via Node question


(Raymond Camden) #1

This has to be a dumb mistake on my part but I’m just not seeing it. I’ve tested the API via Postman and it worked great. I then tried some simple Node code:

const rp = require('request-promise');
        rp({
            uri:'https://languagetool.org/api/v2/check',
            method:'POST',
            formData:{
                'text':'hello world',
                'language':'auto',
                'disabledRules':'EN_QUOTES'
            },
            headers:{
              'Content-Type': 'application/x-www-form-urlencoded'
            }
        })
        .then(res => {
            console.log('res',res);
        })
        .catch(e => {
            console.log('error calling api',e.message);
        });

Pardon the indentation there. Anyway - I always get an error saying that I didn’t pass text or data. When I switch my end point to the Postman Echo service, I clearly see the form fields as being passed. Any ideas?


(Daniel Naber) #2

According to the examples I found on the web, maybe it’s form, not formData?


(Raymond Camden) #3

That did it. Thanks - although it clearly shows formData here. https://www.npmjs.com/package/request-promise

Either way - thank you!