0

While testing the Bulk API in Postman, i got an error at the the 3rd step, when closing the job, and expecting Account to be created. Job gets create in the Org, and stays with an open status. And got i this:

InvalidBatch : Failed to parse CSV. Found unescaped quote. A value with quote should be within a quote. Batch will not be retried.

enter image description here

(But i wont send any quotes in the values, on account information)

previous steps where:

1. create job request:

URL: {{ _endpoint}}/services/data/v{{ version }}/jobs/ingest

type: POST

Body: { "operation" : "insert", "object" : "Account", "contentType" : "CSV", "lineEnding" : "CRLF" }

I had to change "lineEnding" : "CRLF" to "lineEnding" : "LF", as im using Linux and was having this error after PATCH request

ClientInputError : LineEnding is invalid on user data. Current LineEnding setting is CRLF

But the response is HTTP 200 OK

So, job created, Job id ok

2. submit account info

URL:{{ _endpoint}}/services/data/v{{ version }}/jobs/ingest{{_jobid}}/batches

type: PUT

body (raw CSV):

"Name", "Industry"
"Global Treasures & Mapping Company 2", "Education"
"Ahab Mighty Masts 2", "Construction" 
"Planks R Us 2", "Construction"
"Cap Cook Kitchen Supplies 2", "Energy"

response header: HTTP 201 Created

3. patch, closing job

URL:{{ _endpoint}}/services/data/v{{ version }}/jobs/ingest{{_jobid}}

type: PATCH

body (raw JSON):

{
"state":"UploadComplete"
}

Response Header: 200 OK Response body:

{
"id": "750Qy00000GAkZuIAL",
"operation": "insert",
"object": "Account",
"createdById": "005Qy00000BxWDdIAN",
"createdDate": "2025-01-19T22:06:22.000+0000",
"systemModstamp": "2025-01-19T22:06:22.000+0000",
"state": "UploadComplete",
"concurrencyMode": "Parallel",
"contentType": "CSV",
"apiVersion": 62.0
}

The Job concludes, but wont create records, and has an HTTP message 200 OK.

Btw, i'm using postman web interface, and didn't do any changes in my fork, beyond configuring the token, and requests configs above. And dont have any trigger, process builder, flow builder or validation rule active in this org. Using 3 sources, that i tried to follow to the letter:

How to insert Bulk data using Bulk API 2.0 in Salesforce from Postman: https://www.youtube.com/watch?v=6suyzxfzBE8

docs: https://developer.salesforce.com/docs/atlas.en-us.228.0.api_bulk_v2.meta/api_bulk_v2/walkthrough_upsert.htm

Trailhead: https://trailhead.salesforce.com/content/learn/modules/api_basics/api_basics_bulk

Edit 1: I repeated all those steps in the desktop App, and got the same exact result.

Also, trying to simplify, i tested removing the field Industry, and just with the name column, it all works fine. So i just need to figure how to add another field to the CSV body request.

1 Answer 1

0

This is weird: the problem was not line ending, but spaces between comma and quotation marks.

So i replaced

"Name", "Industry"
"Global Treasures & Mapping Company 3", "Education"
"Ahab Mighty Masts 3", "Construction" 
"Planks R Us 3", "Construction"
"Cap Cook Kitchen Supplies 3", "Energy"

With this, it all worked. Added a few fields to test other datatypes

"Name","Industry","NumberOfEmployees","Dark_side__c"
"Global Treasures","Education",5,true
"Ahab Mighty Masts","Chemicals",7,true
"Planks \'R Us","Education",12,true
"Cap Cook Kitchen Supplies","Banking",49,false

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.