Eloqua integration via REST API using JAVA

806 Views Asked by At

Contact standard fields like First Name, Last Name and Email Address have been set via java and integrated using Rest API.

  • Could you please guide me in creating custom objects and custom fields via java using REST API?
  • I can create the same in .NET how to do the same in java?

.NET code is below:

var customObject = new CustomObject
{
    id = -10001,
    name = "Disruption",
    fields = new List<CustomObjectField>
    {
        new CustomObjectField
        {
            name = "FlightNumber",
            dataType = Enum.GetName(typeof(DataType), DataType.text),
            type = "CustomObjectField"
        },
        new CustomObjectField
        {
            name = "FlightDate",
            dataType = Enum.GetName(typeof(DataType), DataType.text),
            type = "CustomObjectField"
        },
        new CustomObjectField
        {
            name = "DisruptionType",
            dataType = Enum.GetName(typeof(DataType), DataType.text),
            type = "CustomObjectField"
        },
        new CustomObjectField
        {
            name = "EmailAddress",
            dataType = Enum.GetName(typeof(DataType), DataType.text),
            type = "CustomObjectField"
        }
    }
};
1

There are 1 best solutions below

0
On

Just create a class representing your data with Java (using ArrayList for JSON arrays):

For your field:

public class customObjectField {
private String FlightNumber;
private String FlightDate;
...
}

For your object:

public class customObject {
private int id;
private String name;
private arrayList<customObjectField> fields;
}

Instantiate then serialize with gson. Then post the String.