# PUT requests to Suspend account using different content-type on 1.5

**URL:** https://meta.discourse.org/t/put-requests-to-suspend-account-using-different-content-type-on-1-5/42789
**Category:** Development
**Created:** [2016年四月19日 03:06 UTC](https://meta.discourse.org/t/put-requests-to-suspend-account-using-different-content-type-on-1-5/42789 "2016-04-19T03:06:25Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![citadelgrad](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/citadelgrad/32/121003_2.png) [@citadelgrad](https://meta.discourse.org/u/citadelgrad)
#### Post date: [2016年四月19日 03:06 UTC](https://meta.discourse.org/t/put-requests-to-suspend-account-using-different-content-type-on-1-5/42789/1 "2016-04-19T03:06:25Z")

</div>

Our site is using Discourse 1.5.1 and I believe our hosting provider upgraded us from 1.4 last week. I have no control over this.

It appears that all API responses from Discourse have the content-type of “application/json”. But I have found that under 1.5 when you issue PUT requests to Suspend an account it now responses with the content-type “text/plain”.

I looked at a number of other PUT requests and they all were using “application/json” so I suspect this was an unintended change.

I’m using the pydiscourse library and until the upgrade didn’t throw any errors for PUT requests. Now every PUT request generates an exception because the library checks the response content-type.

Please let me know if I can provide any additional detail.

 ![](https://global.discourse-cdn.com/meta/original/3X/0/e/0e7ed184dd36e10250a7c9b91118abbfeaca5758.png)

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [2017年三月3日 09:31 UTC](https://meta.discourse.org/t/put-requests-to-suspend-account-using-different-content-type-on-1-5/42789/2 "2017-03-03T09:31:14Z")

</div>

Is this still an issue under 1.7?

---

<div class="post-metadata">

### Author: ![citadelgrad](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/citadelgrad/32/121003_2.png) [@citadelgrad](https://meta.discourse.org/u/citadelgrad)
#### Post date: [2017年三月3日 19:09 UTC](https://meta.discourse.org/t/put-requests-to-suspend-account-using-different-content-type-on-1-5/42789/3 "2017-03-03T19:09:58Z")

</div>

Our site is still on 1.6.3 and is still showing plain text. FYI, I’m not able to upgrade our site. I’ve contacted our host about the upgrade.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [2017年三月3日 20:14 UTC](https://meta.discourse.org/t/put-requests-to-suspend-account-using-different-content-type-on-1-5/42789/4 "2017-03-03T20:14:10Z")

</div>

Any thoughts here @blake?

---

<div class="post-metadata">

### Author: ![blake](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/blake/32/157322_2.png) [@blake](https://meta.discourse.org/u/blake)
#### Post date: [2017年三月3日 21:17 UTC](https://meta.discourse.org/t/put-requests-to-suspend-account-using-different-content-type-on-1-5/42789/7 "2017-03-03T21:17:08Z")

</div>

I have confirmed we are not returning json. I don’t see any recent changes on that controller action that would have broken this, but most of the responses are just set to render `nothing: true`, so I’ll add this to my list since it should probably be returning a success json response.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [2017年五月16日 21:44 UTC](https://meta.discourse.org/t/put-requests-to-suspend-account-using-different-content-type-on-1-5/42789/8 "2017-05-16T21:44:07Z")

</div>

@eviltrout / @blake this is actually a bigger API problem:

1. Are we **strictly** a JSON API, meaning do we expect every single endpoint to always return `render json: success_json` vs `render nothing: true` ?

2. If not, should we always be strict about returning json if the request is made to a `.json` resource ? (which means we need a fancy helper for render success)

As to the OP, I think that is legit that a `PUT` to `/suspend.json` should return a JSON payload. But… just cause you send JSON encoded body does not imply that the server must return JSON.

There is an argument for returning 200 with blank body, you are sending an infinitesimally smaller amount of data and a tiny bit less work on the JS side.

I am leaning towards just going with (1) and making every single `PUT` and `POST` JSON by default, and all XHRs JSON by default.

---

<div class="post-metadata">

### Author: ![blake](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/blake/32/157322_2.png) [@blake](https://meta.discourse.org/u/blake)
#### Post date: [2017年五月16日 23:16 UTC](https://meta.discourse.org/t/put-requests-to-suspend-account-using-different-content-type-on-1-5/42789/9 "2017-05-16T23:16:11Z")

</div>

I personally just care that we return the correct status codes (which we do) so I don’t think this is really a bug.

I do think we should work toward being a strict JSON API though and if we can clean/improve things as we go lets do that.

---

<div class="post-metadata">

### Author: ![citadelgrad](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/citadelgrad/32/121003_2.png) [@citadelgrad](https://meta.discourse.org/u/citadelgrad)
#### Post date: [2017年五月19日 20:33 UTC](https://meta.discourse.org/t/put-requests-to-suspend-account-using-different-content-type-on-1-5/42789/10 "2017-05-19T20:33:44Z")

</div>

> [@blake](#):
>
> I personally just care that we return the correct status codes (which we do) so I don’t think this is really a bug.

I’ve done a fair amount of work over the years with Discourse’s API and it’s always felt really inconsistent. I’m not trying to be critical, but your attitude seems pretty dismissive of something that is clearly inconsistent. I detailed in the first post that all requests that I reviewed returned one way, and after the upgrade to 1.5.1 the API started returning a different content-type in this one particular case. You can chalk this up as not a big deal, but APIs being consistent and reliable is important. If you want to continue to have software that people want use and integrate with you should care about the details.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [2017年五月19日 20:37 UTC](https://meta.discourse.org/t/put-requests-to-suspend-account-using-different-content-type-on-1-5/42789/11 "2017-05-19T20:37:43Z")

</div>

Why can’t we have both.

I think the point @blake is trying to make is that this is not strictly a bug. I agree with that, but one persons bug is another persons feature, and this semantics really does not matter in this case.

Yes, we want to make the API more consistent, I think [my post](https://meta.discourse.org/t/put-requests-to-suspend-account-using-different-content-type-on-1-5/42789/8) offers a good path forward, just waiting on feedback from @eviltrout

---

<div class="post-metadata">

### Author: ![blake](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/blake/32/157322_2.png) [@blake](https://meta.discourse.org/u/blake)
#### Post date: [2017年五月19日 20:57 UTC](https://meta.discourse.org/t/put-requests-to-suspend-account-using-different-content-type-on-1-5/42789/12 "2017-05-19T20:57:14Z")

</div>

We really do appreciate your feedback because we don’t always realize or feel the pain of any inconsistencies or regressions that might occur with the API.

The API is still a priority for us and this year we took a huge step in that direction and actually [documented the API](http://docs.discourse.org), as @sam said we do plan to make the API more consistent, and I also would like to add some API tests so that we can better detect any API regressions.
