Setting the Serving Size for a Recipe via the Genesis API is not immediately obvious. The following guide will help clarify the steps necessary for building a request that will set one of the three options available in the Genesis Food software.
In Genesis Food, you can set the number of servings that a Recipe makes, or you can set how much a single serving weighs, or that a single serving is a certain measure. Each choice requires a specific set of Conversions to be set via the Genesis API.
A Conversion is comprised of a “From” part and a “To” part, and in the case of Serving Size, your “To” part will almost always be in Grams. Each “part” of the Conversion is comprised of a Quantity (typically a Double) and UnitId (a guid). The quantity is how much, the UnitId is what measure it’s in. For example, Quantity = 10, Measure = Grams.
UnitIds are guids that can be found by using the ListUnits endpoint. That endpoint will return a response that contains a collection of all Units, their Names, and their UnitIds. |
How you build the Conversions will determine which Serving Size option is set.
For the first two options, setting “A recipe makes” will automatically calculate a Conversion for “A serving weighs” and vice-versa.
To set the third option, “A serving is,” requires a special case.
Create a Conversion as follows:
From: Quantity = 10, UnitId = a7df0af5-001f-0000-7484-751e8eaf05c6 (i.e. Serving)
To: Quantity = -1, UnitId = a7df0af5-0008-0000-7484-751e8eaf05c6 (i.e. Gram)
The Conversion part of the request would like this:
The result in the Genesis Food application is:
Create a Conversion as follows:
From: Quantity = 1, UnitId = a7df0af5-001f-0000-7484-751e8eaf05c6 (i.e. Serving)
To: Quantity = 97.45, UnitId = a7df0af5-0008-0000-7484-751e8eaf05c6 (i.e. Gram)
The Conversion part of the request would like this:
The result in the Genesis Food application is:
This example will be creating a volume Conversion and then specifying that the serving size should be the newly created volume Conversion. It does not have to be a volume Conversion, but this Serving Size option is typically used for that since either of the first two options can handle all non-volume Conversions. |
Create TWO Conversions as follows:
Create the “Volume” Conversion
From: Quantity = 100, UnitId = a7df0af5-0008-0000-7484-751e8eaf05c6 (i.e. Gram)
To: Quantity = 50, UnitId = a7df0af5-000b-0000-7484-751e8eaf05c6 (i.e. Milliliter)
Create the “Dry” Conversion
From: Quantity = 50, UnitId = a7df0af5-0008-0000-7484-751e8eaf05c6 (i.e. Milliliter)
To: Quantity = 1, UnitId = a7df0af5-000b-0000-7484-751e8eaf05c6 (i.e. Serving)
The Conversion part of the request would look like this:
The results in the Genesis Food application is:
|