title: "Failed to convert value of type 'java.lang.String' to required 'java.util.List'." Or how to convert Python list to Java.util list?
body: <p>This one has the better  of me, for sure.</p>
  <p>I am attempting to use the <a href="https://fdc.nal.usda.gov/fdc-app.html#/" rel="nofollow noreferrer">USDA FoodData Central</a> Rest API for Python, and I have extensively reviewed the related documentation, online materials and SwaggerHub simulations.</p>
  <p><strong>To make a long story short, it seems I need to convert a Python list to a 'java.util.List', something not in <a href="https://fdc.nal.usda.gov/api-guide.html" rel="nofollow noreferrer">the USDA documentation</a>, and something I have not been able to make happen. Despite my efforts, I am unable to even <em>attempt</em> to make that conversion happen, because I cannot install the Python dependencies</strong>.
  It boils down to two questions overall:</p>
  <ol>
  <li>How do I convert a Python list to a Java.Util.List if possible?</li>
  <li>What can I do about the problems installing the dependencies (e.g. jep) when it appears they are deprecated?</li>
  </ol>
  <p>The USDA site sends you to a SwaggerHub simulation. It was helpful, and it gave me the URL pasted below as a model for my API. However, the instructions regarding the <em>required</em> 'fdcIds list' says nothing at all about the need to convert to Java.</p>
  <p><strong>To be clear, the 'fdcIds list' is simply the desired Python list of the six-digit numbers that represent all the food items and products in the USDA database. You can request up to 20 at a time and the API returns a complete nutritional profile of each.
  You will see what I mean if you follow the SwaggerHub link below</strong></p>
  <p>Here is the Swaggerhub model URL with the link below:</p>
  <pre><code>https://api.nal.usda.gov/fdc/v1/foods?fdcIds=173567&amp;fdcIds=173565&amp;fdcIds=173571&amp;format=abridged&amp;nutrients=208&amp;nutrients=204&amp;nutrients=205&amp;api_key=xxxxxxxxxxxxxxxx
  
  https://app.swaggerhub.com/apis/fdcnal/food-data_central_api/1.0.0#/info 
  </code></pre>
  <p>Here are SwaggerHub instructions for the fdcID list pasted in their entirety:</p>
  <pre><code>&quot;fdcIds (reguired)
  array[string]
  (query)
  List of multiple FDC ID's. Should be comma separated list (e.g. fdcIds=534358,373052) or repeating parameters (e.g. fdcIds=534358&amp;fdcIds=373052).&quot;
  </code></pre>
  <p>I think the rest of my code (below) is fine, because otherwise the SwaggerHub simulation produces the desired results.</p>
  <p>Here is the complete error message I received afterwards:</p>
  <hr />
  <pre><code>'error': 'Bad Request',
   'message': &quot;Failed to convert value of type 'java.lang.String' to required &quot;
              &quot;type 'java.util.List'; nested exception is &quot;
              'java.lang.NumberFormatException: For input string: '
              '&quot;[{\'fdcids\':173567},{\'fdcids\':173565},{\'fdcids\':173571},{\'fdcids\':173569},{\'fdcids\':173564}]&quot;',
   'path': '/portal-data/api/v1/foods',
   'status': 400,
   'timestamp': '2022-04-15T21:49:49.609+0000'}
  </code></pre>
  <hr />
  <p>I know Python and JavaScript. I know nothing about Java.</p>
  <p>However, I attempted to install the Python packages necessary for this operation, such as <a href="https://pypi.org/project/install-jdk/" rel="nofollow noreferrer">jdk</a> and <a href="https://pypi.org/project/jep/" rel="nofollow noreferrer">jep</a>, but I ran into additional error messages, as it seems the packages are deprecated(?)  - though I am not sure. I forced the jep installation, but it still did not install successfully.</p>
  <p>The error messages related to the failed installations are too long to paste here; but I will provide examples that seem to represent the gist of the problem.</p>
  <pre><code>error: subprocess-exited-with-error
  error: metadata-generation-failed
  note: This error originates from a subprocess, and is likely not a problem with pip.
  </code></pre>
  <p>I have spent the past several trying to make this API work. I've been working on the related app for almost a year. I will send a request for technical assistance to the USDA, but I could use some help if anyone has some genuine insights or has resolved similar issues.</p>
  <p>The USDA API is a popular one. It apparently works for most developers. I am hoping someone can help. I am a bit mystified by these obstacles.</p>
  <p>My operating system is Windows 10 64 bit.</p>
  <p>My code, as it stands, is pasted below.</p>
  <p>I should note the variables in the URL were originally in a &quot;parameters&quot; dictionary.
  But then, I started to receive error messages stating the dictionary did not contain the fields in the requested URL, which was not true. It seemed to work better when I made them standalone variables...except for the conversion issues related to the fdcIds list.</p>
  <p>At that point, I started to receive error messages like the one in the title related to my failure to convert the Python list to a Java Util.List. I have reviewed all the online information and videos I could find about Python rest apis and possible solutions to the Java conversion problem, including all related questions on Stackoverflow.</p>
  <p>I am at a loss as to how I should proceed.</p>
  <p>Your sincere feedback is much appreciated.</p>
  <p>Thank you for reviewing my question.</p>
  <p>Below, I pasted my code in its entirety. Again, I have also tried to place the variables in the URL inside a parameters dictionary. But it only caused more trouble.</p>
  <pre><code>import requests
  import pprint
  
  api_key = 'AcAm9H2jcFikw4f5PmJl0hFJSjreMwg9BN621tQD'               
  pagesize = 5,
  fdcIds = [{'fdcids': 173567}, {'fdcids': 173565}, {'fdcids': 173571}, {'fdcids': 173569}, {'fdcids': 173564}]
  format = 'abridged'
  dataType = 'SR Legacy'
  foodNutrients = [208, 204,205]
  
  url = f&quot;https://api.nal.usda.gov/fdc/v1/foods?fdcIds={fdcIds}&amp;format={format}&amp;dataType={dataType}&amp;nutrients={foodNutrients}&amp;pagesize={pagesize}'&amp;api_key={api_key}&quot;
  
  headers = {'Content-Type': 'application/json;charset=utf-8'}
  
  data = requests.get(url, headers).json()
  print(requests.status_codes)
  pprint.pprint(data)
  </code></pre>