Comments (4)
As mentioned in bulk API documentation [1],
For jobs with a contentType of CSV, XML is used as the response format except in the case of bulk query results, which are returned in CSV.
To ensure that you retrieve responses in JSON, create a job with a contentType of JSON and use JSON for your batch payloads.
To ensure that you retrieve responses in XML, create a job with a contentType of XML or CSV and use the same format for your batch payloads.
Because of this reason we are getting XML responses for CSV and XML cases. Then we will convert that XML to JSON and return JSON responses in ballerina salesforce bulk API.
For JSON case we will get responses as JSON and return those as it is.
from ballerina-integrator.
Blocker in ballerina-lang: ballerina-platform/ballerina-lang#16965
from ballerina-integrator.
Salesforce bulk client can be created as follows using Salesforce client.
import sfdc46;
string epUrl = "https://<REGION>.salesforce.com";
sfdc46:SalesforceConfiguration sfConfig = {
baseUrl: epUrl,
clientConfig: {
accessToken: ACCESS_TOKEN,
refreshConfig: {
clientId: CLIENT_ID,
clientSecret: CLIENT_SECRET,
refreshToken: REFRESH_TOKEN,
refreshUrl: "https://login.salesforce.com/services/oauth2/token"
}
}
};
// Create salesforce client.
sfdc46:Client sfClient = new(sfConfig);
// Create salesforce bulk client.
sfdc46:SalesforceBulkClient sfBulkClient = sfClient->createSalesforceBulkClient();
Following operator clients are available in the Salesforce bulk client.
- CSV
- CSV insert operator
- CSV upsert operator
- CSV update operator
- CSV delete operator
- CSV query operator
- JSON
- JSON insert operator
- JSON upsert operator
- JSON update operator
- JSON delete operator
- JSON query operator
- XML
- XML insert operator
- XML upsert operator
- XML update operator
- XML delete operator
- XML query operator
Operator can be created as follows.
// Create bulk JSON uploader object. This will create a job to upload JSON contacts as batches.
sfdc46:JsonInsertOperator | sfdc46:SalesforceError jsonInsertOperator = sfBulkClient->createJsonInsertOperator("Contact");
After creating an operator, salesforce job will be created to perform the operation. Then we can add batches to the job
as follows.
// Contacts to be inserted.
json contacts = [
{
description: "Created from Bulk API",
FirstName: "Morne",
LastName: "Morkel",
Title: "SE",
Phone: "0442226670",
Email: "[email protected]",
My_External_Id__c: "201"
},
{
description: "Created from Bulk API",
FirstName: "Andi",
LastName: "Flower",
Title: "SE",
Phone: "0442216170",
Email: "[email protected]",
My_External_Id__c: "202"
}
];
// Upload json as a batch.
sfdc46:Batch | sfdc46:SalesforceError batchDetails = jsonInsertOperator->upload(contacts);
Get batch details, batch request details and batch results can be done as follows.
// Get details of first batch.
sfdc46:Batch | sfdc46:SalesforceError batchInfo = jsonInsertOperator->getBatchInfo(BatchID);
// Get batch request details.
json | sfdc46:SalesforceError batchRequestDetails = jsonInsertOperator->getBatchRequest(BatchID);
// Get batch results.
json | sfdc46:SalesforceError batchResults = jsonInsertOperator->getBatchResults(BatchID);
Get job details, Close or Abort job and get details about all batches of this job can be done as follows.
// Get job details.
sfdc46:Job | sfdc46:SalesforceError jobDetails = jsonInsertOperator->getJobInfo();
// Close the job.
sfdc46:Job | sfdc46:SalesforceError jobClosedDetails = jsonInsertOperator->closeJob();
// Abort the job.
sfdc46:Job | sfdc46:SalesforceError jobAbortDetails = jsonInsertOperator->abortJob();
// Get details about all batches of this job.
sfdc46:BatchInfo | sfdc46:SalesforceError allBatchesInfo = jsonInsertOperator->getAllBatches();
from ballerina-integrator.
Fixed in ballerina-platform/module-ballerinax-sfdc#60
from ballerina-integrator.
Related Issues (20)
- [SMB Connector]Unit tests need to be asserted.
- [VSCode][Windows] Cannot open projects on D: drive
- [JMS Connector]Unit tests need to be added
- [File Integration using Samba]Port should be corrected
- [File Integration Using Samba]Incorrect file name is printed
- [File Integration Using Samba]Error in getting the file size
- [Deploying on Docker][Deploying on Kubernetes][Docs] Mention to set the environmental variables
- [FTP Connector]It only outputs the file size when getting the file size but not the unit.
- [Docs] [Observability] Refactor and Improve Observability docs
- [Logging using Logstash and Kibana] nohup command does not work for windows
- [Docs] SaaS Integration Learn page throws "Page not found"
- [FTP Connector]Cannot read the file content when docker configuration is used
- [File Integration using FTP] Remove unnecessary comments from template
- Issues with Ballerina and Ballerina Plugin in VSCode HOT 1
- [GmailConnector] searchFilter 'query' not working with standard Gmail search query string
- Once a module is being built, it encourages the users to install Ballerina version 1.0.5
- EI Connectors redirect links broken HOT 1
- Module details are not available in Ballerina Central HOT 1
- [Doc] The copy to clipboard feature copies unwanted content
- [FTP Connector][ftp:ClientEndpointConfig]The list() method need to return more clear output
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ballerina-integrator.