Chilkat Online Tools

Java / Salesforce Platform APIs / Upload Job Data

Back to Collection Items

import com.chilkatsoft.*;

public class ChilkatExample {

  static {
    try {
        System.loadLibrary("chilkat");
    } catch (UnsatisfiedLinkError e) {
      System.err.println("Native code library failed to load.\n" + e);
      System.exit(1);
    }
  }

  public static void main(String argv[])
  {
    // This example assumes the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    CkHttp http = new CkHttp();
    boolean success;

    CkBinData bdRequestBody = new CkBinData();
    success = bdRequestBody.LoadFile("file");
    if (success != true) {
        System.out.println("Failed to load file");
        return;
        }

    // Adds the "Authorization: Bearer <access_token>" header.
    http.put_AuthToken("<access_token>");

    CkHttpResponse resp = http.PBinaryBd("PUT","https://domain.com/services/data/v{{version}}/jobs/ingest/{{_jobId}}/batches",bdRequestBody,"text/csv",false,false);
    if (http.get_LastMethodSuccess() == false) {
        System.out.println(http.lastErrorText());
        return;
        }

    System.out.println(resp.get_StatusCode());
    System.out.println(resp.bodyStr());
  }
}

Curl Command

curl -X PUT
	-H "Authorization: Bearer <access_token>"
	-H "Content-Type: text/csv"
	--data-binary '@file'
https://domain.com/services/data/v{{version}}/jobs/ingest/{{_jobId}}/batches

Postman Collection Item JSON

{
  "name": "Upload Job Data",
  "request": {
    "method": "PUT",
    "header": [
      {
        "key": "Content-Type",
        "value": "text/csv"
      }
    ],
    "body": {
      "mode": "file",
      "file": {
        "src": ""
      }
    },
    "url": {
      "raw": "{{_endpoint}}/services/data/v{{version}}/jobs/ingest/{{_jobId}}/batches",
      "host": [
        "{{_endpoint}}"
      ],
      "path": [
        "services",
        "data",
        "v{{version}}",
        "jobs",
        "ingest",
        "{{_jobId}}",
        "batches"
      ]
    }
  },
  "response": [
    {
      "name": "Successful Upload Job Data",
      "originalRequest": {
        "method": "PUT",
        "header": [
          {
            "key": "Content-Type",
            "value": "text/csv"
          }
        ],
        "body": {
          "mode": "file",
          "file": {
            "src": "/Users/username/Downloads/account.csv"
          }
        },
        "url": {
          "raw": "{{_endpoint}}/services/data/v{{version}}/jobs/ingest/{{_jobId}}/batches",
          "host": [
            "{{_endpoint}}"
          ],
          "path": [
            "services",
            "data",
            "v{{version}}",
            "jobs",
            "ingest",
            "{{_jobId}}",
            "batches"
          ]
        }
      },
      "status": "Created",
      "code": 201,
      "_postman_previewlanguage": "plain",
      "header": [
        {
          "key": "Date",
          "value": "Mon, 20 Nov 2023 14:59:59 GMT"
        },
        {
          "key": "Strict-Transport-Security",
          "value": "max-age=63072000; includeSubDomains"
        },
        {
          "key": "X-Content-Type-Options",
          "value": "nosniff"
        },
        {
          "key": "X-XSS-Protection",
          "value": "1; mode=block"
        },
        {
          "key": "Content-Security-Policy",
          "value": "upgrade-insecure-requests"
        },
        {
          "key": "X-Robots-Tag",
          "value": "none"
        },
        {
          "key": "Cache-Control",
          "value": "no-cache,must-revalidate,max-age=0,no-store,private"
        },
        {
          "key": "Sforce-Limit-Info",
          "value": "api-usage=2/15000"
        },
        {
          "key": "Transfer-Encoding",
          "value": "chunked"
        }
      ],
      "cookie": [
      ],
      "body": null
    }
  ]
}