SamDecrock / node-http-ntlm

Node.js module to authenticate using HTTP NTLM
MIT License
192 stars 89 forks source link

Error: www-authenticate not found on response of second request #89

Closed ksampathkumar closed 1 year ago

ksampathkumar commented 4 years ago

Hi,

I have been using node-httpntlp to make REST requests to NAV web services. I get the following error on the PUT request only: err: Error: www-authenticate not found on response of second request at sendType3Message (/home/develop/syncScript_NAV_webservice/esl_NAV_webService/node_modules/httpntlm/httpntlm.js:70:20) at Immediate._onImmediate (/home/develop/syncScript_NAV_webservice/esl_NAV_webService/node_modules/httpntlm/httpntlm.js:101:4) at runCallback (timers.js:705:18) at tryOnImmediate (timers.js:676:5) at processImmediate (timers.js:658:5)

The other requests GET, POST, DELETE all work fine.

Thanks, Kishore.

OluyideO commented 3 years ago

I am experiencing this same error, is there any solution in sight yet

ksampathkumar commented 3 years ago

if it is for a PUT request, make sure you are formatting the eTag properly. The PUT request requires eTag to be sent along the request.

Kishore

OluyideO commented 3 years ago

Thanks for your response, I am doing a post :

async function postNtlm(options) {
  return new Promise((resolve, reject) => {
    httpntlm.post(options, function (err, res) {
      if (err) {
        console.log('ERROR2:' + err);
        console.log('NTLM error:' + JSON.stringify(err));
        reject(err);
      }
      resolve(res);
    });
  });
}

and my request options look like this

async function createHttpNtlmRequestOptions(soapMessage, action) {
  let method = mapActionToMethod(action);
  return {
    url: navUrl,
    username: xxxxxxxx,
    password: xxxxxxxx,
    workstation: 'jupiter',
    domain: '',
    body: soapMessage,
    headers: {
      'Content-Type': 'text/xml',
      'SOAPAction': 'arn:microsoft-dynamics-schemas/codeunit/xxxx:' + method,
    }
idanavr commented 3 years ago

I also get the same error. I have a service that sends a multiple requests and only the first request works, the rest get "www-authenticate not found on response of second request" error. My services working through nginx reverse proxy, if I use the services directly it works normally somehow (it's weird since first request works, no matter which service i'm calling).

Does anyone know how to solve this?

amisora commented 3 years ago

Same error here. Doing a GET request through a devServer proxy.

ksampathkumar commented 3 years ago

Check the web services configuration on the admin side of NAV. Make sure the REST, REST V4 checkboxes are checked. Try restarting the web services and/or nav server. This is mostly with the configuration. Kishore.

SamDecrock commented 1 year ago

I'm guessing the www-authenticate header is not passed on through nginx (or any other proxy you're using)