Closed AndersGerner closed 1 year ago
I don't think that's possible. Are your sure?
Thanks for quick response @SamDecrock :)
For Sharepoint REST API, I need to set the Accept and Content-Type headers to application/json. Otherwise it returns the response in XML.
But it doesn't seem to be working :(
Wouldn't I just update the request object in the options like this?
const options = {
url: 'MySharepointSite,
username: 'USERNAME',
password: '********',
workstation: '',
domain: '',
request: {
'Accept': 'application/json;odata=verbose',
'Content-Type': 'application/json',
},
};
There is no object called request
in my library ;-)
I think this should work:
const options = {
url: 'MySharepointSite',
username: 'USERNAME',
password: '********',
workstation: '',
domain: '',
headers: {
'Accept': 'application/json;odata=verbose',
'Content-Type': 'application/json',
},
};
I'm actually seeing the same thing as the OP. I sent my Content-Type as application/x-www-form-urlencoded and this is what I get in the log:
headers: { 'Content-Type': 'application/x-www-form-urlencoded', Connection: 'keep-alive',
Note how Content-Type is enclosed in single quotes...
Here's the line of code:
headers: { 'Content-Type': "application/x-www-form-urlencoded", "Connection": "keep-alive",
I'm having a similar problem with setting the User-Agent
header in the requests. The server I am connecting to allows me to use NTLM authentication only if User-Agent
is set to a specific value.
I can see from httpntlm.js that is is explicitely not using headers passed in via the options: type1options = _.extend({}, _.omit(httpreqOptions, 'headers', 'body'), type1options);
Indeed, I will add the option to set custom headers back in. But first I need to write some extra tests to make sure I don't break anything.
I added the option to pass in custom headers, see https://github.com/SamDecrock/node-http-ntlm#pass-in-custom-headers for an example. This is available from version 1.8.10
@SamDecrock This commit https://github.com/SamDecrock/node-http-ntlm/commit/f2c71c9a8cc956685b957bb993c601dfdceff245 breaks authorization when used with headers
option.
Basically, v1.8.9 works, v1.8.10 fails.
When trying to set request to have Content-Type header, then it writes the header as 'Content-type' so the server doesn't parse it, because it's written in quotes ' '.
Anybody got an idea on how I can set the header to have content-type: application/json ?
Thanks in advance