# How to set user's location string with Discourse API

**URL:** https://meta.discourse.org/t/how-to-set-users-location-string-with-discourse-api/146301
**Category:** Development
**Created:** [March 31, 2020, 3:43pm UTC](https://meta.discourse.org/t/how-to-set-users-location-string-with-discourse-api/146301 "2020-03-31T15:43:29Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![pnoeric](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pnoeric/32/177144_2.png) [@pnoeric](https://meta.discourse.org/u/pnoeric)
#### Post date: [March 31, 2020, 3:43pm UTC](https://meta.discourse.org/t/how-to-set-users-location-string-with-discourse-api/146301/1 "2020-03-31T15:43:29Z")

</div>

It looks like there’s [an endpoint to set a user’s info](https://github.com/discourse/discourse_api/blob/master/lib/discourse_api/api/users.rb#L32), including their location.

However, I can’t figure out:

1. How to pass the user ID instead of the username?

2. When I post a new location to `mydiscourse.com/u/my_user_name`, I’m getting a 404 error on return… not sure why. I’m using the same code that I used to post other things to the API. So I’m thinking that endpoint is wrong, even though it seems like [that’s what in the API code](https://github.com/discourse/discourse_api/blob/master/lib/discourse_api/api/users.rb#L32). Am I just mis-reading the API code? [Edit: I tried adding `.json` to the endpoint, no luck]

Thank you,  
E

---

<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: [April 1, 2020, 3:05am UTC](https://meta.discourse.org/t/how-to-set-users-location-string-with-discourse-api/146301/2 "2020-04-01T03:05:51Z")

</div>

See [Reverse engineer the Discourse API](https://meta.discourse.org/t/how-to-reverse-engineer-the-discourse-api/20576) while you execute that operation in the user interface.

---

<div class="post-metadata">

### Author: ![pnoeric](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pnoeric/32/177144_2.png) [@pnoeric](https://meta.discourse.org/u/pnoeric)
#### Post date: [April 1, 2020, 3:27pm UTC](https://meta.discourse.org/t/how-to-set-users-location-string-with-discourse-api/146301/3 "2020-04-01T15:27:03Z")

</div>

Thanks Jeff, that was what I needed… being able to spy on the XHR requests directly is clever!

For others who might need the info: I was able to PUT to `/u/username.json` and update the custom fields that way. And it appears you can only make the call with a username, not with a user ID (too bad).
