curl --user administrator:y0uR_P455woR*d \
-H "Content-Type: application/json" \
-X POST http://localhost:8080/midpoint/ws/rest/resources \
-v \
--data-binary @./samples/rest/resource-csv.json
Create Object
Description
Example of creating an midPoint object either representing some identity data in the form of a new User type object or the creation of a new midPoint resource object.
For the purpose of the sample we are using the CURL tool as it is a well maintained, well tested, and it’s widely accessible.
The body of the request will contain data from an external configuration file, the data will be inserted into the request via native Curl commands.
If you are using file as a source for the data in the REST call with curl, please, don’t forget to use '@' before the path to your file. Sometimes the newlines are not correctly handled during the transfer.
(See MID-5229.) If that occurs, please use |
Example
In our examples we are authenticating with the credentials, name "administrator" and password "y0uR_P455woR*d" on a localhost instance running on port 8080. |
For some help regarding the REST examples please see this link:
Show data source example for "Create a new Resource object in MidPoint" | GitHub
{
"resource" : {
"oid" : "ef2bc95b-76e0-59e2-86d6-9999cccccccc",
"name" : "Test CSV: username",
"description" : "Simple CSV resource that is using single identifier (username)",
"connectorRef" : {
"type" : "c:ConnectorType",
"filter" : {
"equal" : {
"path" : "c:connectorType",
"value" : "com.evolveum.polygon.connector.csv.CsvConnector"
}
}
},
"connectorConfiguration" : {
"@ns" : "http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/connector-schema-3",
"configurationProperties" : {
"@ns" : "http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/bundle/com.evolveum.polygon.connector-csv/com.evolveum.polygon.connector.csv.CsvConnector",
"filePath" : "target/midpoint.csv",
"encoding" : "utf-8",
"fieldDelimiter" : ",",
"multivalueDelimiter" : ";",
"uniqueAttribute" : "username",
"passwordAttribute" : "password"
}
},
"schemaHandling" : {
"objectType" : {
"displayName" : "Default Account",
"default" : true,
"objectClass" : "ri:AccountObjectClass",
"attribute" : [ {
"ref" : "ri:username",
"outbound" : {
"source" : {
"path" : "$user/name"
}
}
}, {
"ref" : "ri:firstname",
"outbound" : {
"source" : {
"path" : "$user/givenName"
}
}
}, {
"ref" : "ri:lastname",
"outbound" : {
"source" : {
"path" : "$user/familyName"
}
}
} ],
"activation" : {
"administrativeStatus" : {
"outbound" : { }
}
},
"credentials" : {
"password" : {
"outbound" : { }
}
}
}
},
"capabilities" : {
"configured" : {
"activation" : {
"status" : {
"attribute" : "ri:disabled",
"enableValue" : "false",
"disableValue" : "true"
}
}
}
}
}
}
Show source data for resource for "Create a new Resource object in MidPoint" | GitHub
username,firstname,lastname,disabled,password
user01,Firstname,Lastname,false,secret
user02,Test,Lastname,false,secret
The response is an HTTP 201 code in case of success without a response body. Also, the response contains a Location Header pointing to the location of the created user.
Location: http://localhost:8080/midpoint/ws/rest/resources/ef2bc95b-76e0-59e2-86d6-9999cccccccc