fredsakr / eloqua-csharp-rest-client

Eloqua C# Rest Client
Other
10 stars 51 forks source link

CustomObject endpoint always points to data/customObject #14

Open Yushell opened 8 years ago

Yushell commented 8 years ago

I have the following code for trying to create a CustomObject (Notice I added accountId)

List<FieldValue> coFieldValuesCreate = new List<FieldValue>()
{
    new FieldValue { id = 279, value = "johndoe@a.com" }
};

CustomObject coCreate = new CustomObject();

if (customObjectType == CustomObjectType.Contact)
{
    coCreate.contactId = 775169;
}
else if (customObjectType == CustomObjectType.Account)
{
    coCreate.accountId = 3831189;
}

coCreate.fieldValues = coFieldValuesCreate;

CustomObject createResult = Credentials.client20.Data.CustomObject.Post(coCreate);
customObjectId = createResult.id;

I always get endpoint not found when trying to call CustomObject createResult = myClient.Data.CustomObject.Post(myCustomObject);

I fear this is because Eloqua.Api.Rest.ClientLibrary.Models.Data.CustomObjects.CustomObjects.cs has its resource always poiting to: [Resource("/data/customObject", "CustomObject")]

POST endpoint /api/REST/2.0/data/customObject/{parentId}/instance

DELETE endpoint /api/REST/2.0/data/customObject/{parentId}/instance/{id}

GET endpoint /api/REST/2.0/data/customObject/{parentId}/instance/{id}

PUT endpoint /api/REST/2.0/data/customObject/{parentId}/instance/{id}

How are these used?

I also tried calling CustomObject getResult = Credentials.client20.Data.CustomObject.Get(125);

And still get endpoint not found

Note: Calls for contacts work perfectly.

Source: http://docs.oracle.com/cloud/latest/marketingcs_gs/OMCAC/api-Application-2.0-Custom%20object%20data.html

kvantilburg commented 8 years ago

Yushell,

I ran into this issue as well and have a fix for it. I think it's because the api has changed since the library was written. I'll try to get my changes into pull request this weekend.

Yushell commented 8 years ago

Thank you kvantilburg. I really appreciate your help.

kvantilburg commented 8 years ago

I've created a pull request. I hope it helps.