title: How to build data payload for API in Python?
body: <p>I'm trying to build a data payload to send to an API but I am having issues building it dynamically.  This hard coded payload text works:</p>
  
  <pre><code>"""
  {  
     "Line":[  
        {  
           "Description":"John's Made up Description",
           "Amount":12.00,
           "DetailType":"SalesItemLineDetail",
           "SalesItemLineDetail":{  
              "ItemRef":{  
                 "value":"15"
              },
              "UnitPrice":"2",
              "Qty":6,
              "TaxCodeRef":{  
                 "value":"2"
              }
           }
        }
     ],
     "CustomerRef":{  
        "value":"9"
     },
     "CustomerMemo":{  
        "value":"This is a test"
     }
  }
  """
  </code></pre>
  
  <p>And I've built what I thought was the same with:</p>
  
  <pre><code>data = {}
  data['Line'] = [{"Description" : "John's made up stuff",
                  "Amount" : 12.00,
                  "DetailType" : "SalesItemLineDetail",
                  "SalesItemLineDetail": {
                      "ItemRef" : {
                          "value" : "15"
                      },
                      "UnitPrice" : "2",
                      "Qty" : 6,
                      "TaxCodeRef" : {
                          "value": "2"
                      }
                  }
                  }]
  data['CustomerRef'] = {"value" : "9"}
  data['CustomerMemo'] = {"value" : "hello"}
  </code></pre>
  
  <p>Which returns the following if I do print(data)</p>
  
  <pre><code>{  
     'Line':[  
        {  
           'Description':"John's made up stuff",
           'Amount':12.0,
           'DetailType':'SalesItemLineDetail',
           'SalesItemLineDetail':{  
              'ItemRef':{  
                 'value':'15'
              },
              'UnitPrice':'2',
              'Qty':6,
              'TaxCodeRef':{  
                 'value':'2'
              }
           }
        }
     ],
     'CustomerRef':{  
        'value':'9'
     },
     'CustomerMemo':{  
        'value':'hello'
     }
  }
  </code></pre>
  
  <p>I'm not sure if I have looked at this too long and it's something simple or if I am doing this completely wrong.  How can I dynamically create the correct payload?</p>