UpdateFood (3.1)

UpdateFood (3.1)

Summary: Updates existing foods with the Food instances provided.

Soap Action: http://ns.esha.com/2013/genesisapi/UpdateFood

Request Type: UpdateFoodRequest

  • Foods
    • Type: FoodDto[]
    • The foods to be updated. These foods require an Id value of a food already in the database. If an Ingredient is specified, a NutrientProfile needs to be provided and the NutrientProfileId must be specified on the Ingredient.
  • NutrientProfiles
    • Type: NutrientProfileDto[]
    • The nutrient profiles associated to Ingredients belonging in Foods. The Id value on this type must be specified.

Response Type: UpdateFoodResponse

  • UpdatedFoodsCount
    • Type: Int
    • The number of updated foods.
  • Errors
    • Error[]
    • Gives error information on the foods not updated.
  • Status
    • Type: exlx:ResultStatus
    • The ResultStatus of the given response
  • ResponseVersion
    • Type: exlx:XmlVersion
    • The version of the given response.


SOAP Request (Ingredient)
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:gen="http://ns.esha.com/2013/genesisapi" xmlns:exlx="http://ns.esha.com/2013/exlx" xmlns:typ="http://ns.esha.com/2013/types">
   <soap:Header xmlns:wsa="http://www.w3.org/2005/08/addressing"><wsa:Action>http://ns.esha.com/2013/genesisapi/updatefood</wsa:Action></soap:Header>
   <soap:Body>
      <gen:UpdateFoodRequest>
         <gen:Foods>
            <gen:Ingredient>
               <exlx:Id>752eb9c2-aa4e-7842-bede-d3a51c0fdeba</exlx:Id>
               <exlx:Name>
                  <typ:Value xml:lang="en-US">D-Xylose</typ:Value>
               </exlx:Name>
               <exlx:CommonName>
                  <typ:Value xml:lang="en-US">Xylose</typ:Value>
               </exlx:CommonName>
               <exlx:Description>
                  <typ:Value xml:lang="en-US">Used as a sugar substitute.</typ:Value>
               </exlx:Description>
               <exlx:UserCode>12345-XYLOSE</exlx:UserCode>
               <exlx:DefiningAmount>
                  <exlx:Quantity Type="Double">100</exlx:Quantity>
                  <exlx:UnitId>a7df0af5-0008-0000-7484-751e8eaf05c6</exlx:UnitId>
               </exlx:DefiningAmount>
               <exlx:DefaultWeightUnitId>a7df0af5-0008-0000-7484-751e8eaf05c6</exlx:DefaultWeightUnitId>
               <exlx:Brand>
                  <exlx:Supplier>Am Sweeteners - Middlesex</exlx:Supplier>
                  <exlx:Product>D-Xylose</exlx:Product>
               </exlx:Brand>  
               <exlx:AllergenStatements>
                  <exlx:AllergenStatement>
                     <exlx:AllergenGroups>
                        <!-- Subscribe to Allerens -->
                        <exlx:Id>f01975c0-0191-0000-ff88-2a01e505d63d</exlx:Id>
                     </exlx:AllergenGroups>
                  </exlx:AllergenStatement>
               </exlx:AllergenStatements>
               <exlx:Groups>
                  <!-- Subscribe to Group -->
                  <exlx:Id>021c021f-000a-0000-8d69-0b60293379ea</exlx:Id>
               </exlx:Groups>
               <exlx:AmountCost>
                  <exlx:Amount>
                     <exlx:Quantity Type="Double">100</exlx:Quantity>
                     <exlx:UnitId>a7df0af5-0008-0000-7484-751e8eaf05c6</exlx:UnitId>
                  </exlx:Amount>
                  <exlx:Cost>10</exlx:Cost>
               </exlx:AmountCost>
               <exlx:NutrientProfileId>a7df0af5-0000-0000-7484-751e8eaf05c6</exlx:NutrientProfileId>
            </gen:Ingredient>
         </gen:Foods>
         <gen:NutrientProfiles>
            <gen:NutrientProfile>
                <exlx:Id>a7df0af5-0000-0000-7484-751e8eaf05c6</exlx:Id>
               <exlx:DefiningAmount>
                  <exlx:Quantity Type="Double">100</exlx:Quantity>
                  <exlx:UnitId>a7df0af5-0008-0000-7484-751e8eaf05c6</exlx:UnitId>
               </exlx:DefiningAmount>
               <exlx:NutrientIdVector>
                  <exlx:Entry>
                      <!-- Set Calories to 4 -->
                     <exlx:NutrientId>84a8709a-0000-0000-ebf9-90cea7d9d44f</exlx:NutrientId>
                     <exlx:Quantity Type="Double">4</exlx:Quantity>
                  </exlx:Entry>
                   <exlx:Entry>
                      <!-- Set Protein to 1 -->
                     <exlx:NutrientId>84a8709a-0001-0000-ebf9-90cea7d9d44f</exlx:NutrientId>
                     <exlx:Quantity Type="Double">1</exlx:Quantity>
                  </exlx:Entry>
               </exlx:NutrientIdVector>
            </gen:NutrientProfile>
         </gen:NutrientProfiles>
      </gen:UpdateFoodRequest>
   </soap:Body>
</soap:Envelope>
SOAP Response (Ingredient)
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing">
   <s:Header>
      <a:Action s:mustUnderstand="1">http://ns.esha.com/2013/genesisapi/updatefoodresponse</a:Action>
   </s:Header>
   <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
      <UpdateFoodResponse xmlns="http://ns.esha.com/2013/genesisapi">
         <Errors/>
         <ResponseVersion>1.0.0.0</ResponseVersion>
         <Status>
            <StatusMessage>Ok</StatusMessage>
            <StatusCode>200</StatusCode>
         </Status>
         <UpdatedFoodsCount>1</UpdatedFoodsCount>
      </UpdateFoodResponse>
   </s:Body>
</s:Envelope>
SOAP Request (Recipe)
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:gen="http://ns.esha.com/2013/genesisapi" xmlns:exlx="http://ns.esha.com/2013/exlx" xmlns:typ="http://ns.esha.com/2013/types">
   <soap:Header xmlns:wsa="http://www.w3.org/2005/08/addressing"><wsa:Action>http://ns.esha.com/2013/genesisapi/updatefood</wsa:Action></soap:Header>
   <soap:Body>
      <gen:UpdateFoodRequest>
         <gen:Foods>
            <gen:Recipe>
               <exlx:Id>8980ff36-cd1b-2c23-5ef8-ee69ecb67fee</exlx:Id>
               <exlx:Name>
                  <typ:Value xml:lang="en-US">Sugar Recipe</typ:Value>
               </exlx:Name>
               <exlx:CommonName>
                  <typ:Value xml:lang="en-US">Xylose</typ:Value>
               </exlx:CommonName>
               <exlx:Description>
                  <typ:Value xml:lang="en-US">Used as a sugar substitute.</typ:Value>
               </exlx:Description>
               <exlx:UserCode>12345-XYLOSEREC</exlx:UserCode>
               <exlx:DefaultWeightUnitId>a7df0af5-0008-0000-7484-751e8eaf05c6</exlx:DefaultWeightUnitId>
               <exlx:Brand>
                  <exlx:Supplier>Am Sweeteners - Middlesex</exlx:Supplier>
                  <exlx:Product>D-Xylose</exlx:Product>
               </exlx:Brand>  
               <exlx:AllergenStatements>
                  <exlx:AllergenStatement>
                     <exlx:AllergenGroups>
                        <!-- Subscribe to Allerens -->
                        <exlx:Id>f01975c0-0191-0000-ff88-2a01e505d63d</exlx:Id>
                     </exlx:AllergenGroups>
                  </exlx:AllergenStatement>
               </exlx:AllergenStatements>
               <exlx:Groups>
                  <!-- Subscribe to Group -->
                  <exlx:Id>021c021f-000a-0000-8d69-0b60293379ea</exlx:Id>
               </exlx:Groups>
               <exlx:AmountCost>
                  <exlx:Amount>
                     <exlx:Quantity Type="Double">100</exlx:Quantity>
                     <exlx:UnitId>a7df0af5-0008-0000-7484-751e8eaf05c6</exlx:UnitId>
                  </exlx:Amount>
                  <exlx:Cost>10</exlx:Cost>
               </exlx:AmountCost>
               <exlx:Items>
                  <exlx:FoodItem>
                     <!-- Add item to Recipe  -->
                     <exlx:FoodId>752eb9c2-dbed-7d82-bede-d3a51c0fdeba</exlx:FoodId>
                     <exlx:Amount>
                        <exlx:Quantity Type="Double">100</exlx:Quantity>
                        <exlx:UnitId>a7df0af5-0008-0000-7484-751e8eaf05c6</exlx:UnitId>
                     </exlx:Amount>
                  </exlx:FoodItem>
               </exlx:Items>              
            </gen:Recipe>
         </gen:Foods>
      </gen:UpdateFoodRequest>
   </soap:Body>
</soap:Envelope>
SOAP Response (Recipe)
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing">
   <s:Header>
      <a:Action s:mustUnderstand="1">http://ns.esha.com/2013/genesisapi/updatefoodresponse</a:Action>
   </s:Header>
   <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
      <UpdateFoodResponse xmlns="http://ns.esha.com/2013/genesisapi">
         <Errors/>
         <ResponseVersion>1.0.0.0</ResponseVersion>
         <Status>
            <StatusMessage>Ok</StatusMessage>
            <StatusCode>200</StatusCode>
         </Status>
         <UpdatedFoodsCount>1</UpdatedFoodsCount>
      </UpdateFoodResponse>
   </s:Body>
</s:Envelope>
REST Request (Ingredient)
POST http://localhost:80/rest/FoodEditService.svc/UpdateFood HTTP/1.1
Content-Type: text/plain
Host: localhost:80
 
request={
    "Foods":[{
            "$type":"Esha.DomainModel.Serialization.IngredientDto, Esha.DomainModel.Serialization",
			"Id":"752eb9c2-aa4e-7842-bede-d3a51c0fdeba",
            "Name":{"en-US":"New Ingredient"},
            "CommonName":{"en-US":"New Ingredient Common Name"},
            "UserCode":"xyz-12",
            "Brand":{
                "Supplier":"Am Sweeteners - Middlesex",
                "Product":"Product X"
            },
            "DefiningAmount":{
                "Quantity":{
                    "Type":"Double",
                    "Value":100
                },
                "UnitId":"a7df0af5-0008-0000-7484-751e8eaf05c6"
            },
            "AllergenStatements":[{
                "AllergenGroupIds":[
                    "7d52c4c5-e396-4e8c-ae8e-ca5dd9ddc307",
                ]
            }],
            "GroupsIds":[
                "021c021f-000a-0000-8d69-0b60293379ea"
            ],
            "AmountCost":{
                "Amount":{
                    "Quantity":{
                        "Type":"Double",
                        "Value":100
                    },
                    "UnitId":"a7df0af5-0008-0000-7484-751e8eaf05c6"
                },
                "Cost":"5"
            },
            "NutrientProfileId":"b6fa0af5-0008-0000-7484-751e8eaf05c6"
        }],
    "NutrientProfiles":[
        {
            "Id":"b6fa0af5-0008-0000-7484-751e8eaf05c6",
            "DefiningAmount":{
                "Quantity":{
                    "Type":"Double",
                    "Value":100
                },
                "UnitId":"a7df0af5-0008-0000-7484-751e8eaf05c6"
            },
            "NutrientIdVector":[
                {
                    "NutrientId":"84a8709a-0000-0000-ebf9-90cea7d9d44f",
                    "Quantity":{
                        "Type":"Double",
                        "Value":4
                    },
                },
                {
                    "NutrientId":"84a8709a-0001-0000-ebf9-90cea7d9d44f",
                    "Quantity":{
                        "Type":"Double",
                        "Value":1
                    },
                }              
            ]
        }
    ]
}
REST Response (Ingredient)
{
    "UpdatedFoodsCount": 1,
    "Errors": [],
    "Status": {
        "StatusMessage": 200,
        "StatusCode": 200,
        "StatusDetail": null
    },
    "ResponseVersion": {}
}
REST Request (Recipe)
POST http://localhost:80/rest/FoodEditService.svc/UpdateFood HTTP/1.1
Content-Type: text/plain
Host: localhost:80
 
request={
    "Foods":[{
        "$type":"Esha.DomainModel.Serialization.RecipeDto, Esha.DomainModel.Serialization",
		"Id":"8980ff36-cd1b-2c23-5ef8-ee69ecb67fee",
        "Name":{"en-US":"New Recipe"},
        "CommonName":{"en-US":"New Recipe Common Name"},
        "UserCode":"REC-987",
        "Brand":{
            "Supplier":"Am Sweeteners - Middlesex",
            "Product":"Product X"
        },
        "AllergenStatements":[{
            "AllergenGroupIds":[
                "7d52c4c5-e396-4e8c-ae8e-ca5dd9ddc307",
            ]
        }],
        "GroupsIds":[
            "021c021f-000a-0000-8d69-0b60293379ea"
        ],
        "AmountCost":{
            "Amount":{
                "Quantity":{
                    "Type":"Double",
                    "Value":100
                },
                "UnitId":"a7df0af5-0008-0000-7484-751e8eaf05c6"
            },
            "Cost":"5"
        },
        "Items":[{
            "FoodId":"752eb9c2-aa4e-7842-bede-d3a51c0fdeba",
            "Amount":{
                "Quantity":{
                    "Value":"100","Type":"Double"
                },
                "UnitId":"a7df0af5-0008-0000-7484-751e8eaf05c6"}
        }]
    }]
}
REST Response (Recipe)
{
    "UpdatedFoodsCount": 1,
    "Errors": [],
    "Status": {
        "StatusMessage": 200,
        "StatusCode": 200,
        "StatusDetail": null
    },
    "ResponseVersion": {}
}

Clicking links may navigate you away from the Trustwell site.