Search code examples
salesforcesalesforce-rest-api

How to create a Salesforce Case with attachments using REST API?


I was able to create a new Case using the REST API but i need some help regarding these.

  1. How to create cases in bulk ?
  2. Can we create cases with attachments(CSV) ?

Solution

  • I was able to create case with attachments. we need to use two different APIs

    1. First we need to create case using this api

    /services/data/v55.0/sobjects/Case

    After Creating case it will return Case Id

    1. Second we need to use ContentVersion API

    /services/data/v55.0/sobjects/ContentVersion

    https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_sobject_insert_update_blob.htm

    Convert File to Base64

    payload = json.dumps({
        'Title': 'file.csv',
        'PathOnClient': 'Simple',
        'ContentLocation': 'S',
        'FirstPublishLocationId': caseid,
        'VersionData': Base64
      })