# Creating user lookups in API

**URL:** <https://community.dreamfactory.com/t/creating-user-lookups-in-api/4118>\
**Category:** Authentication & Security\
**Created:** [October 3, 2017, 6:07pm UTC](https://community.dreamfactory.com/t/creating-user-lookups-in-api/4118 "2017-10-03T18:07:32Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![rpalenik](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.dreamfactory.com/rpalenik/32/1067_2.png) [@rpalenik](https://community.dreamfactory.com/u/rpalenik)\
**Post date:** [October 3, 2017, 6:07pm UTC](https://community.dreamfactory.com/t/creating-user-lookups-in-api/4118/1 "2017-10-03T18:07:32Z")

</div>

Hello,  
I am using version 2.9 and I am trying to create user lookup via API and found this article in user docs:

[https://wiki.dreamfactory.com/DreamFactory/Tutorials/Managing\_user\_lookups](https://wiki.dreamfactory.com/DreamFactory/Tutorials/Managing_user_lookups)

Based on that I should be able to do it via command like this:

PUT /api/v2/system/user/100?related=user\_lookup\_by\_user\_id

with body:

```
{"user_lookup_by_user_id": [{
	"name": "favorite_food",
	"value": "pizza",
	"private": false,
	"description": null}

```

I am getting following error:  
“code”: 400,  
“context”: null,  
“message”: “Unknown relationship: user\_lookup\_by\_user\_id”,

Am I doing something wrong or is this a bug?  
Many thanks

UPDATE!!!

I have found also this post in forum:

> [@Using the REST API to change user information and set active to false](https://community.dreamfactory.com/t/using-the-rest-api-to-change-user-information-and-set-active-to-false/2417):
>
> I would like to modify user properties such as first name and last name through a user admin page in my app. I’d also like to be able to set a user as ‘inactive’ through this interface. Is this possible through the REST API? I’ve had a very detailed look through the swagger and the documentation and can’t find anything. I see there is an end point for password reset, are there any others I am unaware of? Many thanks, Doug

I have tried following request in APIdocs:

I used PATCH /system/user/{id} endpoint with following parameters:

id: 2 …user\_id I want to update

body:  
{“user\_lookup\_by\_user\_id”:[  
RelatedLookupResponse {  
“id”:1000,  
“name”: “test”,  
“value”: “test”,  
“created\_date”: “2017-10-03”,  
“last\_modified\_date”: “2017-10-03”,  
}  
]

I get a response code 200 with following information:

{  
“id”: 2  
}

When I look at admin user interface, the lookup key does not show up. What am I doing wrong?

Thanks for your great product.

Richard

---

<div class="post-metadata">

**Author:** ![benc](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.dreamfactory.com/benc/32/1181_2.png) [@benc](https://community.dreamfactory.com/u/benc)\
**Post date:** [June 14, 2018, 5:44am UTC](https://community.dreamfactory.com/t/creating-user-lookups-in-api/4118/2 "2018-06-14T05:44:39Z")

</div>

Did you ever figure out a solution for this? I’m trying to do the exact same thing and having only bad luck. I tried get requests with a few different related tables specified in your second link. A couple work but many (including anything Lookup) do not.

Thanks!  
Ben

---

<div class="post-metadata">

**Author:** ![erikkurtu](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.dreamfactory.com/erikkurtu/32/212_2.png) [@erikkurtu](https://community.dreamfactory.com/u/erikkurtu)\
**Post date:** [June 14, 2018, 3:30pm UTC](https://community.dreamfactory.com/t/creating-user-lookups-in-api/4118/3 "2018-06-14T15:30:31Z")

</div>

I just finally got through this issue. The correct related table for lookups is now “lookup\_by\_user\_id” instead of “user\_lookup\_by\_user\_id.” After making that change, everything worked as expected for me.

---

<div class="post-metadata">

**Author:** ![Erik\_Jacobsen](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.dreamfactory.com/erik_jacobsen/32/1132_2.png) [@Erik\_Jacobsen](https://community.dreamfactory.com/u/Erik_Jacobsen)\
**Post date:** [June 14, 2018, 3:46pm UTC](https://community.dreamfactory.com/t/creating-user-lookups-in-api/4118/4 "2018-06-14T15:46:04Z")

</div>

We will have updated docs on the wiki today. Glad the updated solution worked for you @erikkurtu!

---

<div class="post-metadata">

**Author:** ![benc](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.dreamfactory.com/benc/32/1181_2.png) [@benc](https://community.dreamfactory.com/u/benc)\
**Post date:** [June 14, 2018, 8:05pm UTC](https://community.dreamfactory.com/t/creating-user-lookups-in-api/4118/5 "2018-06-14T20:05:35Z")

</div>

🎉 Thanks @erikkurtu! Changing to “lookup\_by\_user\_id” fixed my issues as well.

I just noticed the original poster was missing related in the patch command so I included my full command for future reference.

```
patch("system/user/{user_id}?related=lookup_by_user_id&fields=*",
  {
    lookup_by_user_id: [
      {
        name: "GroupId",
        value: {myGroupId},
        private: false,
        description: "The group the user is actively working in."
      }
    ]
  }
);
```
