Opened 8 years ago

Closed 8 years ago

#17636 closed feature (wontfix)

store/JsonRest: add option to send post/put as text

Reported by: Simon Speich Owned by:
Priority: undecided Milestone: tbd
Component: Data Version: 1.9.2
Keywords: Cc:
Blocked By: Blocking:


It would be nice if I could have my data posted as a plain POST/PUT. This could be easily provided with an addtional options property (e.g. options.postString} as shown below.

put: function(object, options) {
	options = options || {};
	var id = ("id" in options) ? : this.getIdentity(object);
	var hasId = typeof id != "undefined";
	return xhr(hasId && !options.incremental ? "PUT" : "POST", {
		url: hasId ? + id :,
		postData: options.postString ? object : JSON.stringify(object),
		handleAs: "json",
		headers: lang.mixin({
			"Content-Type": options.postString ? "text/html" : "application/json",
			Accept: this.accepts,
			"If-Match": options.overwrite === true ? "*" : null,
			"If-None-Match": options.overwrite === false ? "*" : null
		}, this.headers, options.headers)

If you work with PHP on the server it's more convenient to be able to access $_POST variables direcly instead of having to json_decode() everything first.

Note: The response will still be JSON.

Change History (2)

comment:1 Changed 8 years ago by Simon Speich

Correction for Content-Type":

"Content-Type": options.postString ? "application/x-www-form-urlencoded" : "application/json",

comment:2 Changed 8 years ago by Colin Snover

Resolution: wontfix
Status: newclosed

JsonRest? is a two-way JSON store only. You may want to look at e.g. instead.

Note: See TracTickets for help on using tickets.