Oracle by Example brandingGet Started with Workers REST API - Create a Worker

section 0Before You Begin

This 20-minute tutorial shows you how to create a pending worker and an employee.

Before you begin, you should know the Manager Assignment Number, Legal Employer Name, Business Unit Name, and Location Code for your environment. Any other objects may be added or modified, as appropriate.


section 1Create a Worker

  1. Add a request to ##_WorkersCollection.

    Add Requests to Collection
  2. Give the request the name Create Employee.
  3. Click Save to ##_WorkersCollection.
  4. Specify the method as POST.
  5. Enter the url:

    {{url}}/hcmRestApi/resources/latest/workers

  6. Give the request the following headers:

    Note: Headers can be saved in presets in postman for reuse.

    Key Value
    REST-Framework-Version 4
    Content-Type application/vnd.oracle.adf.resourceitem+json
    effective-Of RangeStartDate={{4DaysAhead}}
  7. Add the request body. None is selected by default, raw must be used to add content.

    Value replacements will need to be made in the body for your legal employer, business unit, location code, and any other values you would like to replace.

    Request Body:

    {
         "DateOfBirth":"1997-01-01",
    	"names":[{
           "LastName": "##_LastName_{{$timestamp}}",
           "FirstName":"##_FirstName",
           "MiddleNames":"##",
           "LegislationCode": "US"
        }],
        "emails":[
             {
          "EmailType": "H1",
          "EmailAddress": "##_H1_{{$timestamp}}@oracle.com",
          "PrimaryFlag":false,
          "FromDate": "{{5DaysAhead}}"
             },
             {
          "EmailType": "H1",
          "EmailAddress": "##_H1_02_{{$timestamp}}@oracle.com", 
          "PrimaryFlag":false,
          "FromDate": "{{5DaysAhead}}"
             },
             {
          "EmailType": "W1",
          "EmailAddress": "##_Work_{{$timestamp}}@oracle.com", 
          "PrimaryFlag":true
        }],
        "phones":[{
          "PhoneType": "W1",
          "LegislationCode":"US",
          "PhoneNumber": "3333333",
          "AreaCode":"510",
          "CountryCodeNumber":"1",
          "FromDate": "{{5DaysAhead}}",
          "PrimaryFlag":false
              },
              {
          "PhoneType": "H1",
          "PhoneNumber": "1111111",
          "AreaCode":"408",
          "CountryCodeNumber":"1",
          "LegislationCode":"US",
          "FromDate": "{{5DaysAhead}}",
          "PrimaryFlag":true
              },
              {
          "PhoneType": "H1",
          "PhoneNumber": "2222222",
          "AreaCode":"408",
          "CountryCodeNumber":"1",
          "LegislationCode":"US",
          "PrimaryFlag":false
         }],
        "addresses":[{
            "AddressType":"HOME",
            "AddressLine1":"101 Main Street",
            "TownOrCity":"Suwanee",
            "Region1":"Gwinnett",
            "Region2":"GA",
            "PostalCode":"30024",
            "Country":"US",
            "PrimaryFlag":true
              }],
        "ethnicities": [{
         "LegislationCode": "US",
         "Ethnicity": "7",
         "PrimaryFlag":true
             }],
    	"workRelationships":[{
          "LegalEmployerName": "LegalEmployer",
          "WorkerType": "E",
          "EnterpriseSeniorityDate":"{{5DaysAhead}}",
          "LegalEmployerSeniorityDate":"{{5DaysAhead}}",
          "PrimaryFlag":true,
    	  "assignments":[{
    			"BusinessUnitName": "BusinessUnit",
    			"ActionCode": "HIRE_ADD_WORK_RELATION",
    			"LocationCode": "LOC",
    			 "workMeasures":[{
    				 "Value": 1.5,
    				 "Unit": "FTE"
    					  },
    					  {
    				 "Value": 1,
    				 "Unit": "HEAD"
    			}]
    
            }]
        }]
    
    }
  8. Click Send.

    The response should be 201 Created. Make a note of the PersonId, PersonNumber, and AssignmentNumber.

  9. Click Save.
  10. Click Save Response > Save as example.

    Save the Response as an Example
  11. Name the example ## Test Env Create Employee.
  12. Click Save Example.

    The request and response can now be referenced, if necessary.


section 2Create a Pending Worker

Creating a Pending Worker

  1. Add a request to ##_WorkersCollection.

  2. Give the request the name Create Pending Worker.
  3. Click Save to ##_WorkersCollection.
  4. Specify the method as POST.
  5. Enter the url:

    {{url}}/hcmRestApi/resources/latest/workers

  6. Give the request the following headers:

    Note: Headers can be saved in presets in postman for reuse.

    Key Value
    REST-Framework-Version 4
    Content-Type application/vnd.oracle.adf.resourceitem+json
    effective-Of RangeStartDate={{dateStamp}}
  7. Add the request body. None is selected by default, raw must be used to add content.

    Value replacements will need to be made in the body for your legal employer, business unit, location code, manager assignment number and any other values you would like to replace.

    Request Body:

    {
         "DateOfBirth":"1997-01-01",
    	"names":[{
           "LastName": "##_LastName_PND_{{$timestamp}}",
           "FirstName":"##_FirstName",
           "MiddleNames":"##",
           "LegislationCode": "US"
        }],
        "emails":[
             {
          "EmailType": "H1",
          "EmailAddress": "##_H1_PND_{{$timestamp}}@oracle.com",
          "PrimaryFlag":false,
          "FromDate": "{{4DaysAhead}}"
             },
             {
          "EmailType": "H1",
          "EmailAddress": "##_H1_PND_02_{{$timestamp}}@oracle.com", 
          "PrimaryFlag":false,
          "FromDate": "{{4DaysAhead}}"
             },
             {
          "EmailType": "W1",
          "EmailAddress": "##_Work_PND_{{$timestamp}}@oracle.com", 
          "PrimaryFlag":true
        }],
        "phones":[{
          "PhoneType": "W1",
          "LegislationCode":"US",
          "PhoneNumber": "3334444",
          "AreaCode":"510",
          "CountryCodeNumber":"1",
          "FromDate": "{{4DaysAhead}}",
          "PrimaryFlag":false
              },
              {
          "PhoneType": "H1",
          "PhoneNumber": "1114444",
          "AreaCode":"408",
          "CountryCodeNumber":"1",
          "LegislationCode":"US",
          "FromDate": "{{4DaysAhead}}",
          "PrimaryFlag":true
              },
              {
          "PhoneType": "H1",
          "PhoneNumber": "2224444",
          "AreaCode":"408",
          "CountryCodeNumber":"1",
          "LegislationCode":"US",
          "PrimaryFlag":false
         }],
        "addresses":[{
            "AddressType":"HOME",
            "AddressLine1":"102 Main Street",
            "TownOrCity":"Suwanee",
            "Region1":"Gwinnett",
            "Region2":"GA",
            "PostalCode":"30024",
            "Country":"US",
            "PrimaryFlag":true
              },
              {
            "AddressType":"MAIL",
            "AddressLine1":"101 Bell Drive",
            "TownOrCity":"FREMONT",
            "Region1":"Alameda",
            "Region2":"CA",
            "Region3":"Bay Area",
            "PostalCode":"94539",
            "Country":"US",
            "PrimaryFlag":false
         }],
        "ethnicities": [{
         "LegislationCode": "US",
         "Ethnicity": "7",
         "PrimaryFlag":true
             }],
    	"workRelationships":[{
          "LegalEmployerName": "LegalEmployer",
          "WorkerType": "P",
          "PrimaryFlag":false,
       "assignments":[{
            "BusinessUnitName": "BusinessUnit",
    		"LocationCode": "LOC",
    		"ActionCode": "ADD_PEN_WKR",
            "ReasonCode":"PENDWKR",
            "ProposedUserPersonType": "Employee",
            "ProjectedStartDate": "{{4DaysAhead}}",
            "UserPersonType": "Pending Worker",
            "AssignmentName":"Accounting",
            "AssignmentNumber":"E12345678",
    		"managers":[{
                "ManagerAssignmentNumber": "E1224567",
                "ManagerType": "LINE_MANAGER"
                }],
    			 "workMeasures":[{
    				 "Value": 1.5,
    				 "Unit": "FTE"
    					  },
    					  {
    				 "Value": 1,
    				 "Unit": "HEAD"
    			}]
    
            }]
        }]
    
    }
  8. Click Send.

    The response should be 201 Created. Make a note of the PersonId, PersonNumber, and AssignmentNumber. Additionally, copy the link for the workRelationships item as you will need them for the next exercises.

  9. Click Save.
  10. Click Save Response > Save as example.

    Save the Response as an Example
  11. Name the example ## Test Env Create Employee.
  12. Click Save Example.

    The request and response can now be referenced, if necessary.

  13. Save the request.

Set the Ready to Convert Flag

Setting the ready to convert flag is an update to the workRelationship singular resource. To complete this exercise you will need the workRelationship item link from the pending worker's record. If you did not save the results, the next exericse can be used to retrieve the worker record to get the link.

  1. Add a request to ##_WorkersCollection.

  2. Give the request the name Set Ready to Convert Flag.
  3. Click Save to ##_WorkersCollection.
  4. Specify the method as POST.
  5. Enter the url:

    {{url}}/hcmRestApi/resources/latest/workers/{Id}/child/workRelationships/{Id}

  6. Give the request the following headers:

    Key Value
    REST-Framework-Version 4
    Content-Type application/vnd.oracle.adf.resourceitem+json
  7. Add the request body. None is selected by default, raw must be used to add content.

    Request Body:

    {
    "ReadyToConvertFlag":true
    }
  8. Send the request.

    The ReadyToConvertFlag should now be true in the response body.

  9. Save the request.

next stepNext Tutorial

Getting a Worker Using Workers REST API