2

I am trying to obtain values for Customer attributes via the Rest API. Currently, I can retrieve customer attributes, but am unable to determine which specific attribute is associated. For example, given this code (based on https://github.com/Acumatica/AcumaticaRESTAPIClientForCSharp, Endpoint = "Default", EndpointVersion = "18.200.001", Endpoint Library = Acumatica.Default_20.200.001, Acumatica version = Cloud ERP 2020 R1, Build 20.110.0017):

            var customerApi = new CustomerApi(configuration);
            var customers = customerApi.GetList(top: 5, expand: "Attributes", select: "Attributes/Attribute,Attributes/Value");

            foreach (var cust in customers)
            {
                Console.WriteLine(cust.ToString());
            }

Yields this output:

{
  
"AccountRef": {},
  "Attributes": [
    {
      "Value": {
        "value": "True"
      },
      "id": "8de7a85d-6d60-4235-9d35-74a9d08d1cc6",
      "rowNumber": 1,
      "custom": {}
    },
    {
      "Value": {
        "value": "Sample Email Body"
      },
      "id": "8da2a21c-2ba3-45ba-9e12-02122c626e11",
      "rowNumber": 2,
      "custom": {}
    }, ...

enter image description here

enter image description here

What am I missing to be able to get the attribute name returned as well? Or how I am supposed to correlate the given values back to a given attribute?

Jubilsoft-Scott
  • 172
  • 1
  • 10

1 Answers1

1

The default configuration of the Customers API is returning the Attributes array as below for the customerApi.GetList(top: 5, expand: "Attributes", select: "Attributes/Attribute,Attributes/Value"); request

 "Attributes": [
    {
      "Attribute": {
        "value": "Company Revenue"
      },
      "Value": {
        "value": "1,000,000 to 5,000,000"
      },
      "id": "6df69428-7157-438f-8b61-99b2d7d1a3ad",
      "rowNumber": 1,
      "custom": {}
    },
    {
      "Attribute": {
        "value": "Number of Employees"
      },
      "Value": {
        "value": "1-100"
      },
      "id": "15c3f47f-36eb-481b-92c0-f6b2f738732f",
      "rowNumber": 2,
      "custom": {}
    }
  ]

Attributes->Attribute->Value is the identifier for the Attribute which is corresponding to the Description of the Attribute record.

Your result is returned for customerApi.GetList(top: 5, expand: "Attributes", select: "Attributes/Value"); request. Please make sure that you have included the Attributes/Attribute in the select part if you are specifying it.

enter image description here

UPDATE

There is a small difference in naming between 18.200 and 20.200.

In 18.200 the Attribute ID is actually named Attribute
In 20.200 the Attribute ID is renamed to Attribute ID

That is why this request is working correctly for 18.200

namespace Acumatica.Default_18_200_001.Model
{
    [DataContract]
    public class AttributeDetail : Entity_v3
    {

        [DataMember(Name="Attribute", EmitDefaultValue=false)]
        public StringValue Attribute { get; set; }

        [DataMember(Name="RefNoteID", EmitDefaultValue=false)]
        public GuidValue RefNoteID { get; set; }

        [DataMember(Name="Required", EmitDefaultValue=false)]
        public BooleanValue Required { get; set; }

        [DataMember(Name="Value", EmitDefaultValue=false)]
        public StringValue Value { get; set; }

    }
}



namespace Acumatica.Default_20_200_001.Model
{
    [DataContract]
    public class AttributeValue : Entity_v4
    {

        [DataMember(Name="AttributeID", EmitDefaultValue=false)]
        public StringValue AttributeID { get; set; }

        [DataMember(Name="AttributeDescription", EmitDefaultValue=false)]
        public StringValue AttributeDescription { get; set; }

        [DataMember(Name="RefNoteID", EmitDefaultValue=false)]
        public GuidValue RefNoteID { get; set; }

        [DataMember(Name="Required", EmitDefaultValue=false)]
        public BooleanValue Required { get; set; }

        [DataMember(Name="Value", EmitDefaultValue=false)]
        public StringValue Value { get; set; }

        [DataMember(Name="ValueDescription", EmitDefaultValue=false)]
        public StringValue ValueDescription { get; set; }

    }
}
Samvel Petrosov
  • 7,580
  • 2
  • 22
  • 46
  • I am making the call as specified with the proper **select** value. I have learned from your response that **Attributes->Attribute->Value** should return the attribute description and not the attribute Id. Double checking my dataset, the attribute descriptions are populated. I am wondering if somehow my dataset is otherwise misconfigured? – Jubilsoft-Scott Jan 04 '21 at 16:26
  • @Jubilsoft-Scott Could you please add a screenshot of your customer's attribute tab to the question? Have you changed anything in the Web Service Endpoints page? – Samvel Petrosov Jan 04 '21 at 16:29
  • Turns out this is a library issue. My test project was utilizing the Acumatica.Default_20.200.001 library instead of the Acumatica.Default_18.200.001 library. Switching to the version 18 library garnered the desired output. – Jubilsoft-Scott Jan 04 '21 at 16:53
  • 2
    @Jubilsoft-Scott I have updated the answer with details on why the request is not working in 20.200 – Samvel Petrosov Jan 04 '21 at 17:34