Reputation: 21
How May I to add user to Version One ?
I want to use rest api or similar way.
Upvotes: 1
Views: 968
Reputation: 1321
When i create items in version i use a application key "$application_key" and post in php
$post_data = <<<FOO
<Asset>
<Attribute name="Username" act="set">juser</Attribute>
<Attribute name="Password" act="set">swordfish</Attribute>
<Attribute name="Name" act="set">Johnny User</Attribute>
<Attribute name="Nickname" act="set">Johnny</Attribute>
<Attribute name="NotifyViaEmail" act="set">true</Attribute>
<Attribute name="SendConversationEmails" act="set">true</Attribute>
<Relation name="DefaultRole" act="set">
<Asset idref="Role:5" />
</Relation>
</Asset>
FOO;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,'https://www14.v1host.com/v1sdktesting/rest-1.v1/Data/Member');
curl_setopt($ch, CURLOPT_POST, 1); // GET // 1 = POST
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: Bearer {$application_key}",
"Content-Type: application/xml"
]);
$server_output = curl_exec ($ch);
curl_close ($ch);
$simpleXml = simplexml_load_string($server_output);
Upvotes: 0
Reputation: 26699
You may add Member assets via the API.
Adding assets is described on the VersionOne Community Site
First you must know all the required attributes for the Member asset. You may visit the VersionOne instance's metadata API endpoint to discover which attributes are required and where to get valid data for them.
Visiting our test instance Meta api at https://www14.v1host.com/v1sdktesting/meta.v1/?xsl=api.xsl#Member , I see that the attributes Name
, Nickname
, DefaultRole
, NotifyViaEmail
, and SendConversationEmails
are required. We also need Username
and Password
so they can log in.
Role
is a relation so we need to know the related-to Role ID. We visit https://www14.v1host.com/v1sdktesting/rest-1.v1/Data/Role to discover them and choose "Role:5" described as "Developer" for our member.
We can then direct an HTTP POST to /rest-1.v1/Data/Member
with a body such as
<Asset>
<Attribute name="Username" act="set">juser</Attribute>
<Attribute name="Password" act="set">swordfish</Attribute>
<Attribute name="Name" act="set">Johnny User</Attribute>
<Attribute name="Nickname" act="set">Johnny</Attribute>
<Attribute name="NotifyViaEmail" act="set">true</Attribute>
<Attribute name="SendConversationEmails" act="set">true</Attribute>
<Relation name="DefaultRole" act="set">
<Asset idref="Role:5" />
</Relation>
</Asset>
The response body will return the newly created asset XML, or report any errors.
Upvotes: 2