Web API (official plugin)

5 meses atrás
Hi, Elicat1. Can you please tell me what is wrong with the ParseCustomerAttributes method from the CustomerAttributeParser controller, it does not return you any values, or does it work with an error?

Elicat1 wrote:
This request returns XML:

/api-backend/GenericAttribute/GetAttribute/10791?key=CustomCustomerAttributes&entityTypeName=Customer

"
<Attributes>
    <CustomerAttribute ID=\"1\">
        <CustomerAttributeValue>
            <Value>CFGERF12D234R44X</Value>
        </CustomerAttributeValue>
    </CustomerAttribute>
    <CustomerAttribute ID=\"2\">
        <CustomerAttributeValue>
            <Value>ABC45Z</Value>
        </CustomerAttributeValue>
    </CustomerAttribute>
</Attributes>"

I tried to use the "CustomerAttributeParser" endpoints without being able to get the single values ​​...

Is possibile to do extract only values by API ?
5 meses atrás
curl -X 'POST' \
  'https://...../api-backend/CheckoutAttributeParser/ParseCheckoutAttributeValues' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json-patch+json' \
  -d '"<Attributes>
    <CustomerAttribute ID=\"1\">
        <CustomerAttributeValue>
            <Value>CFCFCFCFCFCFCFCF</Value>
        </CustomerAttributeValue>
    </CustomerAttribute>
    <CustomerAttribute ID=\"2\">
        <CustomerAttributeValue>
            <Value>ABC45A</Value>
        </CustomerAttributeValue>
    </CustomerAttribute>
</Attributes>"'

RESPONSE BODY empty:  []  

------------------------------------------------------------------------------------------------------------------------------------------

curl -X 'POST' \
  'https://...../api-backend/CheckoutAttributeParser/ParseCheckoutAttributes' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json-patch+json' \
  -d '"<Attributes>
    <CustomerAttribute ID=\"1\">
        <CustomerAttributeValue>
            <Value>CFCFCFCFCFCFCFCF</Value>
        </CustomerAttributeValue>
    </CustomerAttribute>
    <CustomerAttribute ID=\"2\">
        <CustomerAttributeValue>
            <Value>ABC45A</Value>
        </CustomerAttributeValue>
    </CustomerAttribute>
</Attributes>"'

RESPONSE BODY empty:  []  

------------------------------------------------------------------------------------------------------------------------------------
I Tried also to pass request body as XML ( not as string ) but i have this error:
{
  "errors": {
    "": [
      "Unexpected character encountered while parsing value: <. Path '', line 1, position 1."
    ]
  },
  "type": "https://tools.ietf.org/html/rfc7231#section-6.5.1",
  "title": "One or more validation errors occurred.",
  "status": 400,
  "traceId": "00-78a86337ae14ea4087966b4afe66a32e-b9b3cc2dbe190840-00"
}
------------------------------------------------------------------------------------------------------------------------------------------------
Sergei-k wrote:
Hi, Elicat1. Can you please tell me what is wrong with the ParseCustomerAttributes method from the CustomerAttributeParser controller, it does not return you any values, or does it work with an error?

This request returns XML:

/api-backend/GenericAttribute/GetAttribute/10791?key=CustomCustomerAttributes&entityTypeName=Customer

"
<Attributes>
    <CustomerAttribute ID=\"1\">
        <CustomerAttributeValue>
            <Value>CFGERF12D234R44X</Value>
        </CustomerAttributeValue>
    </CustomerAttribute>
    <CustomerAttribute ID=\"2\">
        <CustomerAttributeValue>
            <Value>ABC45Z</Value>
        </CustomerAttributeValue>
    </CustomerAttribute>
</Attributes>"

I tried to use the "CustomerAttributeParser" endpoints without being able to get the single values ​​...

Is possibile to do extract only values by API ?
5 meses atrás
This query is formed correctly and will return an empty list only if there are no attributes in the database with the specified identifiers in the CustomerAttribute table

Elicat1 wrote:
curl -X 'POST' \
  'https://...../api-backend/CheckoutAttributeParser/ParseCheckoutAttributeValues' \
   -H 'accept: application/json' \
  -H 'Content-Type: application/json-patch+json' \
  -d '"<Attributes>
    <CustomerAttribute ID=\"1\">
        <CustomerAttributeValue>
            <Value>CFGERF12D234R44X</Value>
        </CustomerAttributeValue>
    </CustomerAttribute>
    <CustomerAttribute ID=\"2\">
        <CustomerAttributeValue>
            <Value>ABC45Z</Value>
        </CustomerAttributeValue>
    </CustomerAttribute>
</Attributes>"'

RESPONSE BODY empty:  []  
5 meses atrás
I did not understand your answer ...

As indicated in the previous post this XML is returned to me by this call (customer id = 10791);
so the data IS THERE in the DB

/ api-backend / GenericAttribute / GetAttribute / 10791? key = CustomCustomerAttributes & entityTypeName = Customer

"
<Attributes>
     <CustomerAttribute ID = \ "1 \">
         <CustomerAttributeValue>
             <Value> CFGERF12D234R44X </Value>
         </CustomerAttributeValue>
     </CustomerAttribute>
     <CustomerAttribute ID = \ "2 \">
         <CustomerAttributeValue>
             <Value> ABC45Z </Value>
         </CustomerAttributeValue>
     </CustomerAttribute>
</Attributes> "

I have to add an additional parameter indicating also the customer ID in the call to the endpoint api-backend/ CheckoutAttributeParser/ParseCheckoutAttributeValues' ??


If yes can you send me an example ?

Thanks

Sergei-k wrote:
This query is formed correctly and will return an empty list only if there are no attributes in the database with the specified identifiers in the CustomerAttribute table

curl -X 'POST' \
  'https://...../api-backend/CheckoutAttributeParser/ParseCheckoutAttributeValues' \
   -H 'accept: application/json' \
  -H 'Content-Type: application/json-patch+json' \
  -d '"<Attributes>
    <CustomerAttribute ID=\"1\">
        <CustomerAttributeValue>
            <Value>CFGERF12D234R44X</Value>
        </CustomerAttributeValue>
    </CustomerAttribute>
    <CustomerAttribute ID=\"2\">
        <CustomerAttributeValue>
            <Value>ABC45Z</Value>
        </CustomerAttributeValue>
    </CustomerAttribute>
</Attributes>"'

RESPONSE BODY empty:  []  
5 meses atrás
I suggest you run the following query on your database:

SELECT *  FROM CustomerAttribute where Id IN (1, 2)

Will it return a result? The fact that the data is in the GenericAttribute table does not guarantee its presence in the CustomerAttribute table, since they have no relationship.
5 meses atrás
SELECT *  FROM CustomerAttribute where Id IN (1, 2)
Result:
Id  Name           IsRequired  AttributeControlTypeId  DisplayOrder
1  FiscalCode  0  4  0
2  CodUniv_or_PEC  0  4  0

But Table of CustomerAttributeValue is empty

The values of CustomerAttribute ( 1,2) of CustomerId = 10791 are stored in GenericAttribute:

SELECT * FROM [GenericAttribute] WHERE keyGroup = 'Customer' AND [Key] = 'CustomCustomerAttributes' AND EntityId = 10791

Result:
Id           KeyGroup  Key                                                        Value       EntityId  ....
50111  Customer  CustomCustomerAttributes  xml                 10791           ....

where  value is this XML:
<Attributes><CustomerAttribute ID="1"><CustomerAttributeValue><Value>CFCFCFCFCFCFCFCF</Value></CustomerAttributeValue></CustomerAttribute><CustomerAttribute ID="2"><CustomerAttributeValue><Value>ABC45A</Value></CustomerAttributeValue></CustomerAttribute></Attributes>


Sergei-k wrote:
I suggest you run the following query on your database:

SELECT *  FROM CustomerAttribute where Id IN (1, 2)

Will it return a result? The fact that the data is in the GenericAttribute table does not guarantee its presence in the CustomerAttribute table, since they have no relationship.
5 meses atrás
I didn't notice right away, you've tried a query like this:

curl -X 'POST' \
  'https://...../api-backend/CustomerAttributeParser/ParseCustomerAttributes' \
   -H 'accept: application/json' \
  -H 'Content-Type: application/json-patch+json' \
  -d '"<Attributes>
    <CustomerAttribute ID=\"1\">
        <CustomerAttributeValue>
            <Value>CFGERF12D234R44X</Value>
        </CustomerAttributeValue>
    </CustomerAttribute>
    <CustomerAttribute ID=\"2\">
        <CustomerAttributeValue>
            <Value>ABC45Z</Value>
        </CustomerAttributeValue>
    </CustomerAttribute>
</Attributes>"'


Otherwise, in the code you specify responses from CheckoutAttributeParser, but this is not the controller that you need
5 meses atrás
What is the endpoint that return only values ( no XML ) of CustomerAttributes ( 1,  2) of custumerid = 10791 ?

CFCFCFCFCFCFCFCFID
ABC45A


Sergei-k wrote:
I didn't notice right away, you've tried a query like this:

curl -X 'POST' \
  'https://...../api-backend/CustomerAttributeParser/ParseCustomerAttributes' \
   -H 'accept: application/json' \
  -H 'Content-Type: application/json-patch+json' \
  -d '"<Attributes>
    <CustomerAttribute ID=\"1\">
        <CustomerAttributeValue>
            <Value>CFGERF12D234R44X</Value>
        </CustomerAttributeValue>
    </CustomerAttribute>
    <CustomerAttribute ID=\"2\">
        <CustomerAttributeValue>
            <Value>ABC45Z</Value>
        </CustomerAttributeValue>
    </CustomerAttribute>
</Attributes>"'


Otherwise, in the code you specify responses from CheckoutAttributeParser, but this is not the controller that you need
5 meses atrás
You cannot get such data directly, only first getting XML and then attributes
5 meses atrás
ok is the information I wanted confirmation of.
I'm sorry I didn't ask the direct question before ... maybe we both wasted time ... thanks!

Sergei-k wrote:
You cannot get such data directly, only first getting XML and then attributes