Axcelerate CRM批量导入联系人API调用失败求助
It sounds like your single-request API calls are working, so the core auth and field mapping are solid—great start! The 412 error flagging missing givenName and surname suggests the API isn’t properly parsing your CSV upload. Let’s walk through the most likely fixes:
1. Confirm the API’s Batch Endpoint Requirements
First, double-check Axcelerate’s API docs for batch contact imports:
- Does the endpoint accept CSV uploads, or does it expect a JSON array of contact objects? Many CRM APIs prefer JSON for batch operations even if they support single-object POSTs.
- If CSV is supported, what form field name does it expect? You used
api.contact, but it might be something likecsv_file,contacts_csv, or simplyfile. Using the wrong key will make the API ignore the file entirely, leading to the "undefined fields" error.
2. Fix Postman’s Form-Data Setup
If CSV is indeed supported, adjust your Postman request to match these best practices:
- Method: Ensure you’re using the correct HTTP method (likely
POSTfor batch creates). - Body Tab: Select
form-data(not raw or x-www-form-urlencoded). - Form Field:
- Set the key to the exact name the API specifies (verify via docs or support).
- For the value, choose
Fileand upload your CSV.
- CSV Structure: Use a minimal, clean CSV with no extra whitespace:
Avoid quotes unless your fields contain commas, and make sure the header row matches the API’s required field names exactly (case-sensitive!).givenName,surname Elvis,Presley
3. Correct Request Headers
- Don’t manually set
Content-Type: multipart/form-data: Postman automatically adds this header with the necessaryboundaryparameter when using form-data. Manually setting it can break request parsing. - Keep auth headers identical to your working single request: Ensure your API key, bearer token, or other auth headers are present and correct—same as the requests that successfully synced data.
4. Test with Raw CSV Content
If form-data uploads still fail, try sending the CSV as raw text:
- In Postman’s Body tab, select
rawand set the format toText. - Paste your CSV content directly into the text area.
- Set the
Content-Typeheader totext/csv. - Send the request. If this works, the issue is with how the file is being passed via form-data (likely an incorrect field name).
5. Fallback: Convert CSV to JSON Batch Request
If the API doesn’t support CSV uploads, use a simple script to convert your CSV into a JSON array of contact objects (matching your working single-request structure):
Example Python Script
import csv import requests # Replace with your API details API_URL = "https://your-axcelerate-api-endpoint.com/batch-contacts" AUTH_HEADERS = {"Authorization": "Bearer YOUR_API_TOKEN"} # Read CSV and build contact array contacts = [] with open("contacts.csv", mode="r") as csv_file: csv_reader = csv.DictReader(csv_file) for row in csv_reader: contacts.append({ "givenName": row["givenName"], "surname": row["surname"] # Add any other required fields here }) # Send batch request response = requests.post(API_URL, json=contacts, headers=AUTH_HEADERS) print(f"Response Status: {response.status_code}") print(f"Response Body: {response.text}")
This approach leverages the same structure that worked for your single requests, so it’s almost guaranteed to work if the API supports batch JSON submissions.
6. Debug with Curl
Use Postman’s "Code" feature (top-right corner) to generate a curl command for your request. Run this command in your terminal to rule out Postman-specific issues. For example:
curl --location --request POST 'https://api.axcelerate.com.au/v1/contacts/batch' \ --header 'Authorization: Bearer YOUR_TOKEN' \ --form 'csv_file=@"/path/to/your/test.csv"'
If the curl command returns the same error, the issue is with the request structure, not Postman.
Content of the question originates from Stack Exchange, asked by Jason Rey

