diff --git a/packages/adapter/addon/json-api.js b/packages/adapter/addon/json-api.js index ff9de5bbbe2..d86da31278a 100644 --- a/packages/adapter/addon/json-api.js +++ b/packages/adapter/addon/json-api.js @@ -143,7 +143,7 @@ import { pluralize } from 'ember-inflector'; const JSONAPIAdapter = RESTAdapter.extend({ defaultSerializer: '-json-api', - defaultContentType: 'application/vnd.api+json', + _defaultContentType: 'application/vnd.api+json', /** @method ajaxOptions diff --git a/packages/adapter/addon/rest.js b/packages/adapter/addon/rest.js index 7583c3365ed..16d64b6faa7 100644 --- a/packages/adapter/addon/rest.js +++ b/packages/adapter/addon/rest.js @@ -291,7 +291,7 @@ const hasNajax = typeof najax !== 'undefined'; const RESTAdapter = Adapter.extend(BuildURLMixin, { defaultSerializer: '-rest', - defaultContentType: 'application/json; charset=utf-8', + _defaultContentType: 'application/json; charset=utf-8', fastboot: computed(function() { return getOwner(this).lookup('service:fastboot'); @@ -1095,7 +1095,7 @@ const RESTAdapter = Adapter.extend(BuildURLMixin, { options.headers = {}; } - let contentType = options.contentType || this.defaultContentType; + let contentType = options.contentType || this._defaultContentType; if (get(this, 'useFetch')) { if (options.data && options.type !== 'GET') { @@ -1105,6 +1105,8 @@ const RESTAdapter = Adapter.extend(BuildURLMixin, { } options = fetchOptions(options, this); } else { + // GET requests without a body should not have a content-type header + // and may be unexpected by a server if (options.data && options.type !== 'GET') { options = assign(options, { contentType }); }