# Bug OP-11446 - Endpoint PATCH /api/v3/my_preferences does not update preferences

Project: OpenProject
Status: closed
URL: https://community.openproject.org/work_packages/OP-11446

## Open points

_No work packages_

## Details

| Attribute | Value |
| --- | --- |
| Date |  |
| Priority | Medium |
| Module |  |
| Target versions | 12.4.0 |
| Observed in versions |  |
| Sprint | 12.4.0 |
| Backlog bucket |  |
| Bug found in version (deprecated) |  |
| Found in mobile app version |  |
| Follow-up feedback e-mail |  |
| Requires doc change | No |
| Accessibility | No |
| Pull preview |  |
| List |  |
| Labels |  |

## People

| Attribute | Value |
| --- | --- |
| Assignee |  |
| Accountable |  |
| Product manager |  |
| Developers |  |
| Designer |  |
| Ordered by |  |
| Signed off by |  |
| Interest by |  |

## Planning

| Attribute | Value |
| --- | --- |
| Relevance |  |

## Costs

| Attribute | Value |
| --- | --- |
| Votes |  |
| Work |  |
| Labor costs |  |

## Description

### Steps to reproduce

1.  Use the API V3 to change your user preferences, for instance do as in [the docs](https://www.openproject.org/docs/api/endpoints/userpreferences/#update-my-preferences) and update your time zone:  
    `curl -sSL -X PATCH -H 'Content-Type: application/json' -u apikey:$SOME_API_KEY http://localhost:3000/api/v3/my_preferences -d '{"timeZone": "Europe/Berlin"}'`
2.  Get the preferences back  
    `curl -sSL -X GET -H 'Content-Type: application/json' -u apikey:$OP_API_KEY http://localhost:3000/api/v3/my_preferences`
3.  Filter to get the time zone information only  
    `curl -sSL -X GET -H 'Content-Type: application/json' -u apikey:$OP_API_KEY http://localhost:3000/api/v3/my_preferences | jq .timeZone`

If using [restish](https://community.openproject.org/rest.sh/):

1.  `restish openproject update-user-preferences timeZone: Europe/Paris`
2.  `restish openproject --rsh-filter body.timeZone show-my-preferences`

### What is the buggy behavior?

  - The patch is not updating the preferences. It only prints them.
  - It's because the initial `PATCH /api/v3/my_preferences` is redirected to `/api/v3/users/me/preferences` with a `GET`, because the redirect is a 301 redirect, and [301 may change the method to get](https://developer.mozilla.org/en-US/docs/Web/HTTP/Redirections#permanent_redirections).

### What is the expected behavior?

1.  The endpoint should update the preferences, as [documented](https://www.openproject.org/docs/api/endpoints/userpreferences/#update-my-preferences).

### Environment information

*Please check and fill out the following details to help us identify in what versions and distributions of OpenProject the error occurs*

**OpenProject installation type**

- [ ] Hosted cloud edition
- [ ] Packaged installation
    - What distribution?
- [ ] Docker All-in-one container
- [ ] Docker-compose installation
- [x] Other (please specify)
  - [x] localhost

**OpenProject version**

12.3.3
