Managing user lookups

From DreamFactory
Jump to: navigation, search
DreamFactoryTutorialsManaging user lookups
Line 1: Line 1:
You can use the API to manage user [[DreamFactory/Features/Lookups|lookups]].
+
===You can use the API to manage user [[DreamFactory/Features/Lookups|lookups]].===
  
 
To add user lookups update the user record and include the relationship 'lookup_by_user_id'. In these examples the id of the user is 100 and we are adding a single lookup named 'favorite_food'.
 
To add user lookups update the user record and include the relationship 'lookup_by_user_id'. In these examples the id of the user is 100 and we are adding a single lookup named 'favorite_food'.
Line 88: Line 88:
 
}
 
}
 
</pre>
 
</pre>
 +
 +
==You can also modify these lookups via the API Docs tab==
 +
 +
Migrate over to the System Management endpoint inside of the API Docs tab.
 +
 +
[[File:System Docs Endpoint.png|center|1200px|System Management API Docs|alt=API Docs - System Endpoints]]
 +
Scroll down to the _user/{id} endpoints where you can perform CRUD operations on various lookup keys.
 +
[[File:user_id_endpoints.png|center|1200px|System Management API Docs, _user/{id}|alt=API Docs - System _user/{id} Endpoints]]

Revision as of 17:25, 14 June 2018

You can use the API to manage user lookups.

To add user lookups update the user record and include the relationship 'lookup_by_user_id'. In these examples the id of the user is 100 and we are adding a single lookup named 'favorite_food'.

PUT /api/v2/system/user/100?related=lookup_by_user_id 
{
	"lookup_by_user_id": [{
		"name": "favorite_food",
		"value": "pizza",
		"private": false,
		"description": null
	}]
}

To retrieve user lookups include the relationship 'lookup_by_user_id'. The 'user_id' field for the lookup will be set to 100. This is what links the lookup record to the user record. Since this is the first user lookup in the system its id is set to 1.

GET /api/v2/system/user/100?related=lookup_by_user_id  
{
	"id": 100,
	"name": "Test User",
	"username": null,
	"first_name": "Test",
	"last_name": "User",
	"last_login_date": "2016-09-13 16:28:08",
	"email": "[email protected]",
	"is_active": true,
	"phone": null,
	"security_question": null,
	"confirm_code": "y",
	"default_app_id": null,
	"oauth_provider": null,
	"created_date": "2016-09-20 14:12:59",
	"last_modified_date": "2016-09-20 18:12:59",
	"created_by_id": 1,
	"last_modified_by_id": 10,
	"lookup_by_user_id": [
		{
			"id": 1,
			"user_id": 100,
			"name": "favorite_food",
			"value": "pizza",
			"private": false,
			"description": null,
			"created_date": "2016-09-20 18:25:04",
			"last_modified_date": "2016-09-20 18:25:04",
			"created_by_id": null,
			"last_modified_by_id": null
		}
	]
}

To modify user lookups update the user and provide the new name or value along with the lookup id.

IMPORTANT: You must provide the user_id for the lookups you are updating, otherwise they will be deleted.

PUT /api/v2/system/user/100?related=lookup_by_user_id  
{
	"lookup_by_user_id": [{
		"id": 1,
		"user_id": 100,
  		"value": "grilled cheese"
	}]
}

To delete user lookups update the user and set the user_id for the lookups to delete to null.

PUT /api/v2/system/user/100?related=lookup_by_user_id  
{
	"lookup_by_user_id": [{
		"id": 1,
		"user_id": null
	}]
}

You can also modify these lookups via the API Docs tab

Migrate over to the System Management endpoint inside of the API Docs tab.

API Docs - System Endpoints

Scroll down to the _user/{id} endpoints where you can perform CRUD operations on various lookup keys.

API Docs - System _user/{id} Endpoints