How to Insert an User in the Oracle Field Service Cloud with the Resource Management API

Java

import static java.lang.System.out;

import toatech.resourcemanagement._1.AuthNodeElement;
import toatech.resourcemanagement._1.InsertUserElement;
import toatech.resourcemanagement._1.PropertiesElement;
import toatech.resourcemanagement._1.PropertyElement;
import toatech.resourcemanagement._1.ResourceIdListElement;
import toatech.resourcemanagement._1.ResourceManagementPort;
import toatech.resourcemanagement._1.ResourceManagementService;

public final class OfscSample {

  public static void main(final String[] args) {
    final ResourceManagementService service = new ResourceManagementService();

    final ResourceManagementPort port = service.getResourceManagementPort();

    final InsertUserElement req = new InsertUserElement();

    final AuthNodeElement user = new AuthNodeElement();

    user.setNow("2017-01-01T00:00:00Z");

    user.setLogin("SampleLogin");

    user.setCompany("SampleCompany");

    user.setAuthString("f3a904e1b89e0433f4f9f4a453370f44c3791d632f8ba50757301ba46f11047f");

    req.setUser(user);

    req.setLogin("SampleLogin2");

    final PropertiesElement props = new PropertiesElement();

    final PropertyElement status = new PropertyElement();

    status.setName("status");

    status.setValue("active");

    props.getProperty().add(status);

    final PropertyElement name = new PropertyElement();

    name.setName("name");

    name.setValue("Sample User");

    props.getProperty().add(name);

    final PropertyElement password = new PropertyElement();

    password.setName("password");

    password.setValue("5f4dcc3b5aa765d61d8327deb882cf99"); // MD5 hash

    props.getProperty().add(password);

    final PropertyElement type = new PropertyElement();

    type.setName("type");

    type.setValue("Technician");

    props.getProperty().add(type);

    final PropertyElement language = new PropertyElement();

    language.setName("language");

    language.setValue("br");

    props.getProperty().add(language);

    final PropertyElement timeZone = new PropertyElement();

    timeZone.setName("time_zone");

    timeZone.setValue("Brasilia");

    props.getProperty().add(timeZone);

    req.setProperties(props);

    final ResourceIdListElement resources = new ResourceIdListElement();

    resources.getId().add("1");

    req.setResources(resources);

    out.println(port.insertUser(req));
  }

}

Node.js

Python

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s