Skip to content

Commit e5d9d97

Browse files
author
REDMOND\lahuey
committed
added default content type to POST and PATCH
User headers now overwrite default headers
1 parent b5d0a22 commit e5d9d97

File tree

4 files changed

+39
-12
lines changed

4 files changed

+39
-12
lines changed

lib/graph-js-sdk-web.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,19 @@ var GraphRequest = (function () {
144144
};
145145
GraphRequest.prototype.patch = function (content, callback) {
146146
var url = this.buildFullUrl();
147-
return this.sendRequestAndRouteResponse(new Request(url, { method: RequestMethod_1.RequestMethod.PATCH, body: content, headers: new Headers() }), callback);
147+
return this.sendRequestAndRouteResponse(new Request(url, {
148+
method: RequestMethod_1.RequestMethod.PATCH,
149+
body: content,
150+
headers: new Headers(({ 'Content-Type': 'application/json' }))
151+
}), callback);
148152
};
149153
GraphRequest.prototype.post = function (content, callback) {
150154
var url = this.buildFullUrl();
151-
return this.sendRequestAndRouteResponse(new Request(url, { method: RequestMethod_1.RequestMethod.POST, body: content, headers: new Headers() }), callback);
155+
return this.sendRequestAndRouteResponse(new Request(url, {
156+
method: RequestMethod_1.RequestMethod.POST,
157+
body: content,
158+
headers: new Headers(({ 'Content-Type': 'application/json' }))
159+
}), callback);
152160
};
153161
GraphRequest.prototype.put = function (content, callback) {
154162
var url = this.buildFullUrl();
@@ -246,8 +254,8 @@ var GraphRequest = (function () {
246254
GraphRequest.prototype.configureRequest = function (request, accessToken) {
247255
var _this = this;
248256
request.headers.append('Authorization', 'Bearer ' + accessToken);
249-
Object.keys(this._headers).forEach(function (key) { return request.headers.append(key, _this._headers[key]); });
250257
request.headers.append('SdkVersion', "graph-js-" + packageInfo.version);
258+
Object.keys(this._headers).forEach(function (key) { return request.headers.set(key, _this._headers[key]); });
251259
return request;
252260
};
253261
GraphRequest.prototype.query = function (queryDictionaryOrString) {

lib/src/GraphRequest.js

Lines changed: 11 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)