4

We have defined Asset as:

asset PurchaseOrder identified by orderId {
  o String orderId
    --> SupplierChainParticipant createdBy
    --> SupplierChainParticipant assignedTo
  o String description    
  o String status
  o Integer quantity
  o String assetId    
}

and Participant as :

participant SupplierChainParticipant  identified by participantId {
  o String participantId
  o String identity
  o String type     
}

Now When I am fetching Asset details using REST API of composer-rest-server, I receive response as:

{
  "orderId": "o5",
  "createdBy": "resource:com.supplychain-network.SupplierChainParticipant#p1",
  "assignedTo": "resource:com.supplychain-network.SupplierChainParticipant#p2",
  "description": "New Engine",
  "status": "created",
  "quantity": 1,
  "assetId": "a1"
}

As currently its only returning participantId only while fetching Asset details, Is there a way to fetch details of participant along with Asset as JSON response?

Bob Dalgleish
  • 8,167
  • 4
  • 32
  • 42
deepak parmar
  • 691
  • 1
  • 6
  • 20

2 Answers2

3

If you specify a filter key called include and set the value to resolve then relationships will be resolved and the related assets will also be returned.

Dan Selman
  • 2,287
  • 2
  • 9
  • 18
1

To improve upon the accepted answer with example -

1. 'http://localhost:3000/api/PurchaseOrder?filter={"where":{"orderId":"A01"},"include":"resolve"}'

2. 'http://localhost:3000/api/PurchaseOrder?filter={"include":"resolve"}'
appbootup
  • 9,537
  • 3
  • 33
  • 65