'NodeJS NTML syntax for a POST ressouce
I'm trying to call a webex ressource from my application, but always get the following error : getaddrinfo ENOTFOUND webexapis.com
The thing is, I got a tip I needed to implement a NTLM authentification to comply to the company's proxy policy, but all samples I could find so far concern GET calls.
I have two versions of my code. The first one, voluntarily light, just to check if my syntax is correct. I hope for a "invalid credentials" or a "missing credentials" kind of error, which would tell me I'm on the right tracks :
const credentials: NtlmCredentials = {
username: 'my-app-id',
password: 'my-app-secret',
domaine: 'my-company-domain'
}
const client = NtmlClient(credential);
try {
const response = await client({
url: 'https://webexapis.com/v1/access_token',
method: 'POST'
});
console.log('success: ', response);
} catch(err) {
console.log('error:', err);
}
This is the bloc of code that gives me the getaddrinfo ENOTFOUND error.
I also have a second bloc, more complete, more like what I would need in finite, but that still yields the same error:
const data = qs.stringify({
grant_type: 'authorization_code',
client_id: 'my-client-id',
client_secret: 'my-client_secret',
code: 'auth-code',
redirect_uri: 'my-redirect-uri'
});
const config: AxiosRequestConfig = {
method: 'post',
url: 'https://webexapis.com/v1/access_token',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
data: data
};
axios(config)
.then(res => console.log(JSON.stringify(res.data)))
.catch(err => console.log(err));
Am I missing something obvious or does the problem only depends on my proxy/company configurations ?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
