Skip to content

Create a resource (v2)

Ryan Newington edited this page Mar 9, 2018 · 3 revisions

Used to create a resource in the FIM Service

Request

Method URL
POST /v2/resources/
POST /v2/resources/?return=minimal

Request Body

This request type requires a JSON-formatted list of attribute/value pairs to save with the resource. An ObjectType attribute is required in the body.

Query Parameters

Parameter name Description
{return} Setting return=minimal will prevent the API from returning the newly created resource in the response body. This can also be set by the Perfer request header below.

This API call also supports the advanced resource rendering options

Request Headers

By default, the API will return the full representation of the newly created object in the response body. The Prefer header can be set with a value of return=minimal to prevent the API from returning the newly created resource in the response body. This can save bandwidth when the details of the newly created object are not required. This can also be set by a query parameter as shown above

Response

Response Codes

If the resource was created successfully, the API will return a 201 - Created response, with a Location header indiciating the path to the resource See the topic on error handling for the other response codes that this API call can return.

Response Headers

A URL to the resource will be returned in the Location header

Response Body

If successful, this method will return the newly created resource

Examples

The following example creates an object, and retrieves the full representation of the object in the response

Request

POST /v2/resources/
{
   "ObjectType": "Person",
   "AccountName": "testuser",
   "DisplayName": "Test User"
}

Response

HTTP/1.1 200 OK
Location: http://localhost:63207/v2/resources/c3be8d94-0c07-429e-9105-f17d2c5b581e
{
	"ObjectType": "Person",
	"ObjectID": "c3be8d94-0c07-429e-9105-f17d2c5b581e",
	"CreatedTime": "2016-09-12T03:28:33.380",
	"Creator": "6437407e-eb9f-4eb9-9be5-d37bbf0be67a",
	"AccountName": "testuser",
	"DisplayName": "Test User"
}

The following example creates an object, and specifies that the server does not need to return the object in the response

Request

POST /v2/resources/
Prefer: return=minimal
{
   "ObjectType": "Person",
   "AccountName": "testuser",
   "DisplayName": "Test User"
}

Response

HTTP/1.1 200 OK
Location: http://localhost:63207/v2/resources/c3be8d94-0c07-429e-9105-f17d2c5b581e