Inhalte aufrufen


Link addresses and customers using the WebApi

  • Bitte melden Sie sich an, um eine Antwort zu verfassen.
1 Antwort zu diesem Thema

#1 est



  • Members
  • 1 Beiträge

Geschrieben: 15 July 2016 - 09:37

Hello SmartStore Community,


I'm in the process of importing existing data into SmartStore. I try to use the odata WebApi as much as possible (instead of 'manually' executing queries on the SmartStore DB). The customers and addresses are already imported so they only need to be linked. For products there are some handy shortcuts as I've seen in the documentation: http://docs.smartsto...roduct Examples . It seems there is no such 'navigation link' for the addresses of a customer.


What I have tried is patching an existing customer and pass a list of Address IDs, like I've seen in the odata tutorial For example, I want to assing addresses with IDs 1 and 2 to a customer with ID 1. The following doesn't seem to work. I get an error containing "An unexpected 'PrimitiveValue' node was found when reading from the JSON reader".

PATCH urlbase/odata/v1/Customers(1)

    "Addresses" : [1,2]

This way of patching works with 'normal' properties.


I also tried to pass the addresses as JSON objects (containing only the address ID as property), but then I receive another error 'Cannot apply PATCH to navigation property'. It would be nice if someone could provide a sample update request for addresses of a customer.


Thanks in advance

#2 Marcus Gesing

Marcus Gesing

    SmartStore AG

  • Administrators
  • 3424 Beiträge

Geschrieben: 15 July 2016 - 15:29

The navigation property "Addresses" is a collection of type Address and not of a primitive type. OData request of type '~/entityset/key/navigation/key' are not supported on customers yet. These paths are not supported out of the box. I've created an issue for that.

Schöne Grüße aus Düsseldorf,
Marcus Gesing