I'm a beginner with the Salesforce API and recently, I've been trying make bulk API requests and convert the response into a pandas DataFrame, however, the results I'm having a tough time with are results in the format,

{'name': 'John',
'lastName': 'Doe',
'RecordType': {'attributes': '......', 'name': 'Customer'}}

Is there a way to convert this output into something like

{'name': 'John',
'lastName': 'Doe',
'RecordType_Name': 'Customer'}

Thank you for your help in advance.

  • 2
    SF response is JSON, I feel, its more suited on Stack Overflow than SFSE – Pranay Jaiswal Aug 19 '19 at 12:42
  • You probably can't modify api responses, but you could modify your code (not featured) to understand the response better. Stackoverflow will have much better python/pandas support than here. I suggest you include your code along with your sample response. – battery.cord Aug 19 '19 at 14:06

The Bulk API supports XML, JSON, and CSV formats for input and output. Both XML and JSON formats will return to you nested objects as you depict when you query relationship fields.

If you want a flat file, use the CSV format Bulk API, which will flatten nested objects into a single column set.

While most of the examples in the Bulk API documentation use JSON or XML format, CSV is well supported. You'll need to specify that format when you create the Bulk API job and when you load your query batch; if you're using a connector library, it will likely have its own semantics for specifying the content type.

|improve this answer|||||

Not the answer you're looking for? Browse other questions tagged or ask your own question.