Creating user lookups in API

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

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:

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

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

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.

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

:tada: 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."
      }
    ]
  }
);
1 Like