I tried to create the below code, but I am getting error:
<# Set up the SuiteTalk REST API base URL
base_url = f'https://{account_id}.
suitetalk.api.netsuite.com/services/rest/record/v1'
# Set up the headers for API requests
headers = {
'prefer': 'transient',
'Content-Type': 'application/json',
'Cookie': 'NS_ROUTING_VERSION=LAGGING'
}
# Read the CSV file and encode it as a Base64 string
csv_file_path = '/Users/yogi/Downloads/Vendors/sample/sample_vendor_ns.csv'
with open(csv_file_path, 'rb') as file:
csv_data_base64 = base64.b64encode(file.read()).decode()
# Create a new CSV import job
csv_import_job = {
'recordType': 'Vendors', # Set the target record type, e.g., 'customer'
'mappingId': '431', # Set the internal ID of your saved CSV import, if applicable
'csvFile': csv_data_base64, # Set the Base64-encoded CSV data
}
response =
requests.post(f'{base_url}/csvimport', auth=oauth, headers=headers, data=json.dumps(csv_import_job))
if response.status_code == 201:
job_id = response.json()['id']
print(f'CSV import job created with ID: {job_id}')
else:
print('Failed to create CSV import job:', response.text)>