code: def create_payload(entities):
          
          #First check that all entities are of the same type
          types = {e.etype for e in entities}
          if len(types) != 1:
              raise ValueError("Can't create payload with " +
                               str(len(types)) + " types")
  
          all_attrs = set()
          for e in entities:
              all_attrs.update(set(e.attrs.keys()))
  
          #Write a header line
          all_attrs = list(all_attrs)
          header = "entity:" + entities[0].etype + "_id"
          payload = '\t'.join([header] + all_attrs) + '\n'
  
          for e in entities:
              line = e.entity_id
              for a in all_attrs:
                  line += '\t' + e.attrs.get(a, "")
              payload += line + '\n'
  
          return payload
docs: Create a tsv payload describing entities.
  
          A TSV payload consists of 1 header row describing entity type
          and attribute names. Each subsequent line is an entity_id followed
          by attribute values separated by the tab "\\t" character. This
          payload can be uploaded to the workspace via
          firecloud.api.upload_entities()